For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


Create a new Cordova app without the MobileFirst template

We can create a new Cordova app that contains MobileFirst features with a few simple commands.


Before you begin


Overview

You enter all of the commands in the following steps from your command window.


Procedure

  1. To initially create your Cordova application, enter cordova create AppName where AppName is the name of the application that you are creating. For example, the following command creates an application named MyApp:

    cordova create MyApp

    Important: We can optionally include a MobileFirst template when you initially create your app. In this case, some Cordova plug-ins are added for you automatically. For more information, see Creating a new Cordova app with the MobileFirst template.

  2. Enter cd AppName to change to the root directory of your new app.
  3. To add platforms to our app, enter cordova platform add platform where platform is ios, windows, or android, or any combination of these platforms.

    Important: Verify that the version of the platform that you add is supported by IBM MobileFirst Platform Foundation. For a list of minimum supported platform version levels, see Supported Cordova components for MobileFirst cross-platform apps. The latest available platform versions will be downloaded by default with the commands described in this step. To download a previous version of a platform, specify the version number by using the syntax cordova platform add platform@version. For example: cordova platform add windows@4.3.0. For example, the following command adds the iOS, Android, and Windows platforms:

    cordova platform add ios android windows

  4. To add the IBM MobileFirst Platform Foundation SDK plug-in, enter cordova plugin add cordova-plugin-mfp.

    Note: If we used the MobileFirst template when you created your app, you do not have to complete this step because the cordova-plugin-mfp plug-in has already been added to our app.

  5. To add additional Cordova plug-ins for MobileFirst, enter cordova plugin add plugin where plugin is one of the following:

    • cordova-plugin-mfp-push
    • cordova-plugin-mfp-jsonstore
    • cordova-plugin-mfp-fips
    • cordova-plugin-mfp-encrypt-utils

    For example, the following command installs MobileFirst FIPS 140-2 for Android and JSONStore support:

    cordova plugin add cordova-plugin-mfp-fips cordova-plugin-mfp-jsonstore

  6. Optional: Add other Cordova plug-ins that might be used by your app. For more information see The Command-Line Interface ("Add Plugin Features" section) on the Apache Cordova web site.

    For example, to add the Cordova whitelist plug-in:

    cordova plugin add cordova-plugin-whitelist Or, for example, to add the CrossWalk plug-in:

    cordova plugin add cordova-plugin-crosswalk-webview --variable XWALK_VERSION="org.xwalk:xwalk_core_library:15+"

    Note: Some versions of CrossWalk can cause a problem when you run the app on an Android emulator. For more information, see Known limitations.


Results

You now have a Cordova app that is enabled for IBM MobileFirst Platform Foundation. In the case of the example used here, the Cordova application MyApp has the iOS and Android platforms installed, and also has FIPS 140-2 support for Android and JSONStore support (for all platforms) installed. The Cordova whitelist and CrossWalk plug-ins are optionally installed.


What to do next

To further develop your app with features that depend on the MobileFirst Server, register your app with the server. For more information, see Registering Cordova applications from the MobileFirst Platform CLI.

Important: (Android and iOS development only.) If you are developing your app for the Android or iOS platforms, when you add the platform to our app that contains the cordova-plugin-mfp plug-in, an existing file in your app is replaced by a version of the file that is provided by MobileFirst Platform Foundation. These files are:

If you made any changes to the original versions of these files, we must merge the changes that you made into the new version of the file that is provided by IBM MobileFirst Platform Foundation.

Parent topic: Creating Cordova apps that include MobileFirst features