I am using cordova 6.0.0 and cordova-platform-android 6.0.0 for developing my ionic app. I have added the one signal plugin in initialization scripts. The script looks like below.
sudo cordova platform add ios
sudo cordova platform add android
sudo ionic resources
sudo cordova plugin add onesignal-cordova-plugin
sudo cordova plugin add cordova-plugin-crosswalk-webview
sudo cordova plugin add ionic-plugin-keyboard
sudo cordova plugin add cordova-plugin-whitelist
sudo cordova plugin add cordova-plugin-console
sudo cordova plugin add cordova-plugin-splashscreen
sudo cordova plugin add cordova-plugin-network-information
sudo cordova plugin add cordova-plugin-screen-orientation
sudo cordova plugin add cordova-plugin-inappbrowser
sudo cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git
sudo cordova plugin add cordova-plugin-vibration
sudo cordova plugin add https://github.com/VersoSolutions/CordovaClipboard.git
In my ionic app in the app.js file I called the OneSignal init method as below.
ionic.Platform.ready(function () {
app.run(function () {
var notificationOpenedCallback = function(jsonData) {
//console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
};
console.log('oneSignal plugin', window.cordova.plugins.OneSignal);
window.cordova.plugins.OneSignal.init("my-one-signal-app-id",
{googleProjectNumber: "my-google-app-id"},
notificationOpenedCallback);
window.cordova.plugins.OneSignal.enableInAppAlertNotification(true);
});
});
But when I run the app it displays as below
oneSignal plugin undefined
app.js:29 Uncaught TypeError: Cannot read property 'init' of undefined
Is it an issue with cordova 6.0.0 or I have done any wrong with the approach?