Push Notification notificationCallback working only once

Hi,

I’ve managed to receive push notifications on my app following the push from scratch tutorial

However, something is really weird: the function I’ve defined as onNotification callback works only during the first run of the App. If I close the app, then opens it again, I DO get the notification, but I don’t get the function I’ve defined as callback being called.

This is my code (inside a login Controller):

Ionic.io();
new Ionic.Push({
//“debug”: true,
“onNotification”: function(notification) {
alert(‘a’);
},
“onRegister”: function(data) {
alert(‘b’);
}
});
push.register();

I’ve already tried putting this code in the .run() function. Also no success… am I missing something here?

Hello, phonegap-plugin-push released a new version that may fix your problem ( it did for me ).
check : https://github.com/phonegap/phonegap-plugin-push/blob/master/CHANGELOG.md

( to update : cordova plugin add phonegap-plugin-push )

Put your onNotification, after your “pluginConfig” ( cf : https://github.com/driftyco/ng-cordova/issues/963#issuecomment-152867351 )

Hi Smezer,

Thanks for the tip, it started working (with the same code). I guess it was indeed a bug.