Search code examples
cordovaionic-frameworkibm-cloud

IBM Cordova push plugin with ionic


Just trying to get the IBM cordova push plugin working with Ionic. The documentation is good for Cordova, but there is no guidance for Ionic. Just looking for the best way to approach this. thanks


Solution

  • As @beaver mentioned in his comment, there should be no major difference, Cordova is still used in Ionic projects so you can manage cordova plugins in an Ionic project like you'd manage them in a Cordova project. This said, you can follow the same documentation for setting cordova client plugin for bluemix with the following exceptions:

    In the section titled: Installing the Cordova plug-in

    1. Instead of step 2 of the tutorial, install cordova and ionic using npm install -g cordova ionic
    2. Instead step 3 of the tutorial, create your ionic project using ionic start myApp blank
    3. Instead of step 5 and 6 of the tutorial, first add your required platforms using ionic platform add android or ionic platform add ios then follow step 5 of the tutorial to set the minimum versions.

    In the section titled: Initializing the cordova plug-in

    This is the important part, the IBM bluemix plugin must be initialised after the Ionic framework has completed loading, that's why we need to modify step 1 of this section, instead of adding the initialization code globally in index.js, add it before the end of the $ionicPlatform.ready function like the code below

    angular.module('starter', ['ionic']).run(function($ionicPlatform) {
      $ionicPlatform.ready(function() {
        // some initialization code
        // then 
        if(BMSClient)
          BMSClient.initialize("app-route", "app-guide");
      });
    })