0

使用 Cordova PushPlugin 和 AngularJS 我想接收推送通知并读取有效负载中的 URL,然后在通知被滑动打开时导航到该页面。

这是如何实现的?

我试过这个,但这是在 angular 之外的全局函数内部,所以我不会怀疑 $location 可以工作。虽然它不会抛出任何错误,但它也不会从有效负载导航到 url。

function onNotificationAPN(event) {
  $location.path(event.custom.url)
});
4

1 回答 1

1

你可以试试这个:创建一个服务“PushService”并像下面这样调用服务

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

}

我创建了一个工具来生成具有与cordova 和ionic 集成的推送通知的应用程序。您可以查看Ionic 应用程序生成器

于 2014-07-27T06:03:05.197 回答