Monday, 21 November 2016

FREE Notifications using OneSignal Ionic cordova


cordova plugin add onesignal-cordova-plugin

angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {    
    // Enable to debug issues.
    // window.plugins.OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});

    var notificationOpenedCallback = function(jsonData) {
      alert("Notification received:\n" + JSON.stringify(jsonData));
      console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
    };

    // Update with your OneSignal AppId and googleProjectNumber before running.
    window.plugins.OneSignal.init("<one signal>",
                                   {googleProjectNumber: "<google id>"},
                                   notificationOpenedCallback);
  });

})


No comments:

Post a Comment