检测推送通知是否在等待phonegap

时间:2013-10-16 08:58:39

标签: javascript jquery mobile cordova

我正在使用带有phonegap的pushplugin来发送/接收推送通知。

我想知道是否有办法检测这种情况(android和ios):

  • 推送通知发送至手机
  • 用户不会从通知中启动应用
  • 时间过去
  • 用户直接启动应用
  • 在应用中显示一条提醒,指导用户使用推送通知,从推送通知中加载数据的新内容
  • 然后,如果可能,从手机本机通知托盘/控制台
  • 中删除推送通知

我正在使用代码按照pushplugin指南处理通知,因此对于ios:

注册设备:

pushNotification.register(tokenHandler, errorHandler {
    "badge":"true","sound":"true","alert":"true","ecb":"onNotificationAPN"
})

处理通知:

function onNotificationAPN(e) {
    if (e.alert) {
        // code here to show new content, works if user launches app through the notification
    }
}

类似于android:

注册设备:

pushNotification.register(successHandler, errorHandler, {
    "senderID":"571716295846","ecb":"onNotificationGCM"
});

处理通知:

function onNotificationGCM(e) {
    if(e.payload){
        //code to show new content, works when launched through notification
    }
}

1 个答案:

答案 0 :(得分:0)

据我所知,找出是否收到推送通知的唯一方法是当应用程序处于活动状态并且您收到通知时。

应用程序自身无法访问收到的推送通知,因为这些是由操作系统处理的。所以我担心答案是否定的,你不能......

相关问题