APN and GCM Push Notifications opening a url in cordova app

妖精的绣舞 提交于 2019-12-12 02:03:43

问题


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:


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



来源:https://stackoverflow.com/questions/24477660/apn-and-gcm-push-notifications-opening-a-url-in-cordova-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!