I'm using the pushplugin with phonegap to send/ receive push notifications.
I'm wondering if there is a way to detect this scenario (android and ios):
I'm using the code to handle notifications as per the pushplugin guide, so for 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:
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...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.