Saleforce Mobile SDK and Ionic – Setup the Mobile SDK

Saleforce Mobile SDK and Ionic – Setup the Mobile SDK

Saleforce Mobile SDK and Ionic – Setup the Mobile SDK

Brett M. Nelson - Tuesday, June 27, 2017

Last time we looked at the tools we would be working with to make an mobile app.  Let's start getting those tools ready to use.

Install Things

Ok so the install is pretty easy.  npm install forcedroid -g and your done.

npm install forcedroid -g

PS D:\Workspace\Blog\salesforce\ionic> npm install forcedroid -g C:\Users\brettmn\AppData\Roaming\npm\forcedroid -> C:\Users\brettmn\AppData\Roaming\npm\node_modules\forcedroid\forcedroid.js C:\Users\brettmn\AppData\Roaming\npm `-- forcedroid@5.1.0 `-- shelljs@0.7.8 +-- glob@7.1.2 | +-- fs.realpath@1.0.0 | +-- inflight@1.0.6 | | `-- wrappy@1.0.2 | +-- inherits@2.0.3 | +-- minimatch@3.0.4 | | `-- brace-expansion@1.1.8 | | +-- balanced-match@1.0.0 | | `-- concat-map@0.0.1 | +-- once@1.4.0 | `-- path-is-absolute@1.0.1 +-- interpret@1.0.3 `-- rechoir@0.6.2 `-- resolve@1.3.3 `-- path-parse@1.0.5

PS D:\Workspace\Blog\salesforce\ionic>

As I mentioned last time this depends on having Apache Cordova install so let's get that as well

npm install cordova@6.4.0

PS D:\Workspace\Blog\salesforce\ionic> npm install cordova@6.4.0 -g npm WARN deprecated node-uuid@1.4.8: Use uuid module instead C:\Users\brettmn\AppData\Roaming\npm\cordova -> C:\Users\brettmn\AppData\Roaming\npm\node_modules\cordova\bin\cordova C:\Users\brettmn\AppData\Roaming\npm `-- cordova@7.0.1 +-- configstore@2.1.0 | +-- dot-prop@3.0.0

// // More stuff

+-- semver-diff@2.1.0
\`-- string-length@1.0.1

PS D:\Workspace\Blog\salesforce\ionic>

At the time of this writing there is  a breaking change in Cordova 7.0.0 we will need Cordova version 6.4.0 that's what the @6.4.0 is for.

Since we are building android we will need to install the Android Studio.  Head over to there to get it and follow the instructions for the install.

With those installed we can create a project.

Forcedroid Create

There are 2 ways to create a poject with forcedroid with the create command or with the createWithTemplate since I don't have a template in mind I will use the create command.

So lets run forcedroid create Iwill be provided parameters so that I can repeat the process easier if I make a mistake.

forcedroid create --apptype=hybrid_local --appname=contacts --packagename=com.wipdeveloper.contacts --organization="WIP" --outputdir=contacts

PS D:\Workspace\Blog\salesforce\ionic> forcedroid create --apptype=hybrid_local --appname=contacts --packagename=com.wipdeveloper.contacts --organization="WIP" --outputdir=contacts

******************************************************************************** * * Creating android hybrid_local application using Salesforce Mobile SDK * with app name: contacts * package name: com.wipdeveloper.contacts * organization: WIP * * in: contacts * * from template repo: * template path: HybridLocalTemplate * plugin repo: * ********************************************************************************

Creating a new cordova project. D:\Workspace\Blog\salesforce\ionic\contacts D:\Workspace\Blog\salesforce\ionic com.wipdeveloper.contacts@1.0.0 D:\Workspace\Blog\salesforce\ionic\contacts `-- shelljs@0.7.0 +-- glob@7.1.2 | +-- fs.realpath@1.0.0 | +-- inflight@1.0.6 | | `-- wrappy@1.0.2 | +-- inherits@2.0.3 | +-- minimatch@3.0.4

//  // More stuff  //

******************************************************************************** * * Next steps: * * Your application project is ready in contacts. * To use your new application in Android Studio, do the following: * - open contacts\platforms\android in Android Studio * - build and run * Before you ship, make sure to plug your OAuth Client ID and Callback URI, and OAuth Scopes into contacts\www\bootconfig.json * ********************************************************************************

PS D:\Workspace\Blog\salesforce\ionic>

Let's look at what those parameters meant.

We have just set up our project after installing the Mobile SDK.  There are a few more steps before we can run this small sample app against our org so let's take a look at that next time.


Not too difficult yet but if you have hit a snag let me know by leaving a comment below, emailing or following and yelling at me on Twitter/BrettMN.