I'm trying to integrate OneSignal into my Ionic v1 project. I've installed the plugin, referenced the OneSignal.js file in my index.html, and added this to my app.js:
var notificationOpenedCallback = function(jsonData) {
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
};
window.plugins.OneSignal
.startInit("MY_APP_ID")
.handleNotificationOpened(notificationOpenedCallback)
.endInit();
I've also tried adding this wrapper:
if(window.plugin != undefined){
var notificationOpenedCallback = function(jsonData) {
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
};
window.plugins.OneSignal
.startInit("MY_APP_ID")
.handleNotificationOpened(notificationOpenedCallback)
.endInit();
}
The error disappears, but the push notification isn't working when I build and run on my device in iOS.
Any suggestions as to how to get OneSignal integrated into my Ionic v1 app?