Starting Your First App
This guide shows you how to set up a project. If you are coming from any of the samples, note that (most of) these steps have already been done ahead of time.
Platform Compatibility
We test our library against the following platforms:
- iOS
- Android
The minimum version supported for each platform depends on the version of PhoneGap/Cordova. We support PhoneGap/Cordova version 5.x and above.
If you are using PhoneGap together with Angular, you should use the Kinvey AngularJS library.
Add an App Backend
In the Kinvey console, create a new app backend. If you are currently viewing another app backend, click the app's name in the left navigation, and the select "New App" in the menu.
On the app dashboard page, you will find your App Key
and App Secret
in the top right. You’ll need those to configure your app.
Set Up the PhoneGap environment
Follow the PhoneGap Getting Started Guide to set up a PhoneGap environment.
Add Kinvey SDK
You can add the Kinvey SDK to your project in one of two ways - using the package we ship, or using the source code.
We recommend that you download the Kinvey PhoneGap SDK and save it to a file locally in your project.
Additional Steps
To use external JavaScript libraries, like Kinvey, you need to add our hosts to the whitelist. In www/config.xml
, add the following before the </widget>
tag:
<access origin="https://baas.kinvey.com*" />
<access origin="https://da189i1jfloii.cloudfront.net*" />
<access origin="https://storage.googleapis.com*" />
Configure Your App
To use the SDK, you need to initialize it with your App Key and App Secret.
Kinvey.init({
appKey: '<appKey>',
appSecret: '<appSecret>'
});
The initialization function accepts the following options when initializing the library:
Option | Description |
---|---|
appVersion | Set a version for your app that will be sent as the header X-Kinvey-Client-App-Version on every network request. |
defaultTimeout | Set the default request timeout (in milliseconds). The default value is 60,000 ms. |
storage | Selects a storage provider. Possible values: Kinvey.StorageProvider.WebSQL (default1), Kinvey.StorageProvider.LocalStorage , Kinvey.StorageProvider.IndexedDB , Kinvey.StorageProvider.SessionStorage , Kinvey.StorageProvider.Memory . |
Notes:
1 The default setting may not work in all web browsers that you target with your app. You may need to choose another local storage provider depending on your requirements.
instanceId
to the ID of their dedicated Kinvey instance to correctly setup the backend and Mobile Identity Connect API URLs for the library.
You can find your Instance ID on the dashboard of the Kinvey Console, next to your App Key and App Secret.
Kinvey.init({
appKey: '<Your App Key>',
appSecret: '<Your App Secret>',
instanceId: '<Your Instance ID>'
});
Example of an instanceId
would be:
instanceId: 'kvy-us2'
Master Secret
in client-side code.
Verify Set Up
Your app is now connected to Kinvey. The ping
method, as shown below, will contact the backend and verify that the SDK can communicate with your app.
var promise = Kinvey.ping().then(function(response) {
console.log('Kinvey Ping Success. Kinvey Service is alive, version: '
+ response.version
+ ', response: '
+ response.kinvey
);
}).catch(function(error) {
console.log('Kinvey Ping Failed. Response: ' + error.description);
});
hello
instead of hello app-name
, please make sure you have configured your app. If the error yields This app backend not found
, the app key
and app secret
you entered are incorrect.
Every App has an Active User
Your app will be used by a real-life human being. This person is represented by the Active User. This user object must explicitly be created, either with a username and password, OAuth sign-on (such as Facebook, Google+, LinkedIn, etc.), or Mobile Identity Connect. See the User Guide for more information.
What's next
You are now ready to start building your awesome apps! Next we recommend diving into the User Guide or Data Store Guide to learn more about our service, or explore the sample apps to go straight to working projects.