0

Using Cordova PushPlugin and AngularJS I want to receive a push notification and read a URL in the payload and then navigate to that page when the notification is swiped open.

How is this accomplished?

I tried this, but this is inside of a global function that is outside of angular so I wouldn't suspect the $location to work. It doesn't throw any errors though, but it also does not navigate to the url from the payload.

function onNotificationAPN(event) {
  $location.path(event.custom.url)
});
ajbraus
  • 2,909
  • 3
  • 31
  • 45

1 Answers1

1

You can try this: Create a service "PushService" and invoke the service like below

function onNotification(event) {
var injector = angular.element(document.body).injector();
injector.invoke(function (PushService) {
    PushService.onNotification(event);
});

}

I created a tool to generate app with push notification integration with cordova and ionic. You can check it out Ionic app builder

Saravanan S
  • 1,021
  • 1
  • 10
  • 24