Wondering if anyone has looked into this and weather it's possible with the Generic Push Plugin.... What I am wanting to do is push some additional data/code to the devices so I can do things like take users to specific pages or execute arbitrary code based upon the push message. A typical APNS payload would look something like this...
{"aps":{"alert":"The Arizona Rattlers are Live On Cox7 Arizona.","sound":"beep.wav"}}
But after reading the APNS protocol should support additional JSON data like my 'page' key below...
{"aps":{"alert":"The Arizona Rattlers are Live On Cox7 Arizona.","sound":"beep.wav","page":"live"}}
for testing I tried pulling the 'page' data out of the message using this code....
function onNotificationAPN(event) {
if (event.alert) {
//alert('push-notification: ' + event.alert + '');
navigator.notification.alert(event.alert);
}
if (event.sound) {
var snd = new Media(event.sound);
snd.play();
}
if (event.badge) {
pushNotification.setApplicationIconBadgeNumber(successHandler, event.badge);
}
if (event.page) {
navigator.notification.alert(event.page);
}
}
But I don't see the alert with the custom payload.
Has anyone looked into this? Thanks as always...
Sean
Help get this topic noticed by sharing it on
Twitter,
Facebook, or email.
Twitter,
Facebook, or email.
-
Custom payloads are not currently surfaced in the current plugin. A new version, due out this week will surface the entire payload for Android.
We will look into surfacing the entire payload for iOS in a subsequent update. -
-
-
-
I should also mention that your above json example is not quite correct. You need to put any custom key/value pairs outside of the aps namespace. The aps namespace is reserved by Apple.
GOOD:
{
"aps":{
"alert":"The Arizona Rattlers are Live On Cox7 Arizona.",
"sound":"beep.wav"
},
"page":"live"
}
BAD:
{
"aps":{
"alert":"The Arizona Rattlers are Live On Cox7 Arizona.",
"sound":"beep.wav",
"page":"live"
}
} -
-
Thanks Bob. Yea, I just threw that together as an example. Thanks for all the work you are putting into PGB
-
-
OK. The plugin now on build surfaces all elements to the web app. Let me know if you are still unable to see your custom key/value pair(s)
-
Loading Profile...



EMPLOYEE
