APN and GCM Push Notifications opening a url in co

2019-08-31 00:45发布

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)
});

1条回答
走好不送
2楼-- · 2019-08-31 01:18

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

查看更多
登录 后发表回答