Friday 22 April 2016

Creating your first Cordova Hybrid Android App Using Salesforce MobileSDK(For Linux Users)

Inorder to create an hybrid android first user has to install node packages: like npm,nodejs.
Install:npm:sudo apt-get install -g npm.
Installing nodejs:sudo npm install -g nodejs.
Installing cordova globally:sudo npm install -g cordova
Detailed steps in creating project is:
Step-1:
$:>cordova create TestApp com.test.app TestApp.
Step-2:
Edit index.html,force.js/forcetk.mobilesdk.js,bootconfig.json files
Step-3:
Add cordova sdk plugin,
$:>cordova plugin add https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin
Step-3:
Add necessary cordova plugins depends on requirement:
$:>cordova plugin add <cordova-plugin-name> --save
Eg's:
$:>cordova plugin add cordova-plugin-inAppBrowser --save
$:>cordova plugin add cordova-plugin-statusbar --save
$:>cordova plugin add cordova-plugin-dialogs --save
.... so on.
Step-4:
Now, install shelljs to run salesforce mobile sdk script when adding android as platform.
Install shelljs@0.5.3
$:>npm install shelljs@0.5.3
Step-5:
Now, here we will add platform  using cordova.
$:>cordova platform add android@5.0.0
An android project will get generate under "platforms"  folder.
Step-6:
To run apk the user has to import project into Eclipse ADT/Android studio to build and run the project.
Step-7:
To deploy new changes done in www/*.html,*.js files then user has to call cordova to reflect changes in android side.The command used to deploy changes are:
$:>cordova prepare.