Push Notification onNotificationAPN problem


I use the Push Notification Plugin from phonegap-build:

In the doc, when I register the callbacks, I need to do something like this:

    errorHandler, {

, that means I need to something in the onNotificationAPN function.

In the github README doc, onNotificationAPN is a global function, so it’s OK.
However, in my case, I want to show a view when user clicks the push notification,that means I need to register a function within my controller other than global, so I can call $location or $scope to change the view.

I try this:

$scope.onNotificationAPN = function(event) {
    alert('onNotificationAPN scope');
var args = {"badge":"true", "sound":"true", "alert":"true", "ecb":"$scope.onNotificationAPN"};
pushNotification.register(tokenHandler, errorHandler, args);

it can not work.
What’s the right way to achieve this?


To show a particular view you can try this:
var redirectToView = function(object) {
var url = ‘/URL_to_view’;
$rootScope.$apply(function() {

and call this method in $scope.onNotificationAPN


There are angularjs wrappers available for the pushnotifications plugin that might fix your problem. I am using this one:

And a week ago I found another nice one:


Hello Frank,

may you show me a complete example? I am trying to get working
this plugin but without success.

Thank you in advance!



Have you solved this? would you be willing to share your code? I also would like my push notifications to open a url, but I’m having the same problem with the global function callback not being in sync with angular.

I tried ng-cordova $cordovaPush, but the docs are so sparse (but so well styled . . . ).