Monday, November 14, 2016

IBM MobileFirst Platform 8.0 - Developing Applications (Adding the MobileFirst SDK to Cordova Applications)

Hi folk, again back with new developments. I will start a series of post about the development of applications for mobile devices based on IBM MobileFirst Platform.

The idea is to learn new concepts about: MobileFirst-provided APIs for Native, Cordova and Web applications, such as JSONStore and WLResourceReuest.
The MobileFirst Cordova SDK is provided as a set of Cordova plug-ins, and is registered at NPM.
NPM is the package manager for JavaScript.

Available plug-ins are:
  • cordova-plugin-mfp - The core SDK plug-in
  • cordova-plugin-mfp-push - Provides push notifications support
  • cordova-plugin-mfp-jsonstore - Provides JSONStore support
  • cordova-plugin-mfp-fips - Android only. Provides FIPS support
  • cordova-plugin-mfp-encrypt-utils - iOS only. Provides support for encryption and decryption
The Cordova platform versions supported by the MobileFirst plug-ins, are:
  • cordova-ios: >= 4.1.1 and < 5.0
  • cordova-android: >= 5.1.1 and < 6.0
  • cordova-windows: >= 4.3.2 and < 5.0
Prerequisites:
  • Apache Cordova CLI 6.x and MobileFirst CLI installed on the developer workstation.
  • A local or remote instance of MobileFirst Server is running.
  • Setting up your Cordova development environment.
Before you start, make sure that the MobileFirst Server is running.

Procedure:

1. Check Cordova version
$ cordova -v
6.1.1

2. Create Cordova project
$ cordova create MyHelloCordova jif.example.hellocordova MyHelloCordova --template cordova-template-mfp
Creating a new cordova project.
Retrieving cordova-template-mfp using npm...


Note:
“MyHelloCordova” is the folder name of the application
“jif.example.hellocordova” is the ID of the application
“MyHelloCordova” is the Name of the application
--template modifies the application with MobileFirst-specific additions
Because the application was configured using the MobileFirst template, the MobileFirst core Cordova plug-in is added automatically.



3. Change directory to Cordova project:
$ cd MyHelloCordova

4. Add one or more supported platforms to the Cordova project by using the Cordova CLI command: cordova platform add ios|android|windows. For example:
$ cordova platform add android

5. Registering the application to MobileFirst Server
$ mfpdev app register
Verifying server configuration...
Registering to server:'http://####.####.####.####:9080' runtime:'mfp'
Updated config.xml file located at: /Users/jorge/Development/Mobile/mfp/workspace/MyHelloCordova/config.xml
Run 'cordova prepare' to propagate changes.
Registered app for platform: android


Note: You can also register applications from the MobileFirst Operations Console

6. Propagate changes and run the example
$ cordova prepare
$ cordova emulate


No comments:

Post a Comment