[英]detect if push notification is waiting phonegap
I'm using the pushplugin with phonegap to send/ receive push notifications. 我正在使用带phonegap的pushplugin发送/接收推送通知。
I'm wondering if there is a way to detect this scenario (android and ios): 我想知道是否有一种方法可以检测到这种情况(android和ios):
I'm using the code to handle notifications as per the pushplugin guide, so for ios: 我正在使用代码按照pushplugin指南处理通知,因此对于ios:
to register device: 注册设备:
pushNotification.register(tokenHandler, errorHandler {
"badge":"true","sound":"true","alert":"true","ecb":"onNotificationAPN"
})
to handle a notification: 处理通知:
function onNotificationAPN(e) {
if (e.alert) {
// code here to show new content, works if user launches app through the notification
}
}
similarly with android: 与android类似:
register device: 注册设备:
pushNotification.register(successHandler, errorHandler, {
"senderID":"571716295846","ecb":"onNotificationGCM"
});
handle notification: 处理通知:
function onNotificationGCM(e) {
if(e.payload){
//code to show new content, works when launched through notification
}
}
As far as I know the only way to find out if you receive a push notification is when the application is active and you receive the notification. 据我所知,找出是否收到推送通知的唯一方法是当应用程序处于活动状态并且收到通知时。
The application self can't access the received push notifications because those are handled by the os. 应用程序自身无法访问收到的推送通知,因为这些推送通知是由操作系统处理的。 So I'm afraid the answer is no, you can't...
所以,恐怕答案是否定的,你不能...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.