The HelloTodo sample contains a Cordova project that you can use to learn.
Clone the samples with the following command:
git clone https://github.com/ibm-bluemix-mobile-services/bms-samples-cordova-hellotodo
Before you can run the HelloTodo application, you must set up an app on Bluemix. The following procedure shows you how to create a MobileFirst Services Starter application. A Node.js runtime environment is created so that you can provide server-side functions, such as resource URIs and static files. The Cloudant® NoSQL DB, Push Notifications, and Mobile Client Access services are then added to the app.
Create a mobile backend in the Bluemix dashboard:
- In the Boilerplates section of the Bluemix catalog, click MobileFirst Services Starter.
- Enter a name and host for your mobile backend and click Create.
- Click Finish.
Navigate into your project directory and run the following commands:
cordova platform add ios
cordova platform add android
Add the plugin:
cordova plugin add bms-core
Follow the README instructions for Configuration to configure your development environment.
Note: Project will not build until you follow instructions from this step.
- Navigate to the directory where the project was cloned.
- Open index.js located at [your-directory]/www/js/index.js
- Replace the
"SERVER_URL"
and set your region. - Make sure your route is using https.
JavaScript:
// Bluemix credentials
//
// Create a MobileFirst Services starter service instance and copy the route e.g. "https://myhostname.mybluemix.net"
route: "SERVER_URL",
// deviceready Event Handler
//
// Set the region: BMSClient.REGION_US_SOUTH, BMSClient.REGION_UK, or BMSClient.REGION_SYDNEY
onDeviceReady: function() {
BMSClient.initialize(BMSClient.REGION_US_SOUTH);
},
Note: Don't forget commas at the end of each line!
Now you can run your application in your mobile emulator or on your device.
-
Build the Cordova app. From your terminal enter the following command:
cordova build ios cordova build android
-
You will need to make native code changes to your application to initialize
BMSAuthorizationManager
. Follow the documentation here for instructions. -
Run the sample app from Android Studio or Xcode after making the native changes.
Check the following items:
- Verify that you correctly pasted the route value without the slash at the end.
- Double check the README of the core plugin to ensure your development environment is set up correctly.
- Check the Xcode or Android debug log for more information.
- Check the status of your App in Bluemix.
This package contains sample code provided in source code form. The samples are licensed under the under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 and may also view the license in the license.txt file within this package. Also see the notices.txt file within this package for additional notices.