APN和GCM推送通知在科尔多瓦的应用程序打开一个网址 [英] APN and GCM Push Notifications opening a url in cordova app

查看:200
本文介绍了APN和GCM推送通知在科尔多瓦的应用程序打开一个网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用科尔多瓦PushPlugin和AngularJS我想收到一个推送通知和有效载荷读取URL,然后在通知刷卡打开导航到该页面。

这是如何实现的?

我想这一点,但是这是一个全局函数,该函数的角度之外,所以我不会怀疑$位置在里面工作。它不抛出任何错误,虽然,但它也不会浏览到从有效载荷的URL。

 函数onNotificationAPN(事件){
  $ location.path(event.custom.url)
});


解决方案

您可以试试这个:创建一个服务PushService,并调用该服务像下面

 函数onNotification(事件){
变种注射器= angular.element(document.body的).injector();
injector.invoke(功能(PushService){
    PushService.onNotification(事件);
});

}

我创建生成与科尔多瓦和离子推送通知的应用程序集成的工具。你可以检查出来离子应用生成

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

解决方案

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

这篇关于APN和GCM推送通知在科尔多瓦的应用程序打开一个网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆