It’s hard to tell from your sample, but I’m assuming that onNotificationAPN
is a global function outside of Angular. Generally speaking, Angular doesn’t talk to the outside world. So, you have to resort to a few hacks to get that global function to talk to angular.
Here’s how I do it:
document.addEventListener('push-notification', function(event) {
var body = document.getElementsByTagName("body")[0];
var appController = angular.element(body).scope();
appController.reportNotificationReceived(event);
});
Here’s an explanation of how this works : http://calendee.com/2014/05/12/custom-urls-in-ionic-cordova-apps/
Also, here’s another post about similar subject : How to integrate Cordova/Phonegap plugins within Angular/Ionic the right way?