after upgrade my app to new ionic beta 11 my push notification don"t work,
document.addEventListener(‘deviceready’, function () {
// Enable to debug issues.
// window.plugins.OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});
let appId = “”;
let googleProjectNumber = “”;
var notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ’ + JSON.stringify(jsonData));};
window.plugins.OneSignal.init(appId,{googleProjectNumber: googleProjectNumber},notificationOpenedCallback);
// Show an alert box if a notification comes in when the user is in your app.
window.plugins.OneSignal.enableInAppAlertNotification(false);
}, false);
// my cli say widows.plugins doesn’t exist
Try this
initPush() {
var notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
};
window["plugins"].OneSignal.init("googleKey",
{googleProjectNumber: "appID", autoRegister: true},
notificationOpenedCallback);
window["plugins"].OneSignal.enableInAppAlertNotification(true);
}
1 Like
Thanks it works now:heart_eyes
@LoLStats This worked for me too. The current documentation for Ionic2 Native - OneSginal needs some improvements. I was only able to resolve the promise once / fire the notificationOpenedCallback once.
1 Like
Yea the documentation is not the best…