Please change it to:
alert(JSON.stringify(event));
it'll print all event's data, so you will be able to see parameters where message is
Please change it to:
alert(JSON.stringify(event));
it'll print all event's data, so you will be able to see parameters where message is
Hi Sergiy, thks for your msg.
alert(JSON.stringify(event)
as you advised doesn't work on all devices:
. ok on motoG Android 5
. no alert pops up on Note3 Android 5
however, since it shows the all string on MotoG :
{"isTrusted":"false","notification":{"aps":{"alert":"myMsg"}}}
I could make the Note3 prompting the alert with the myMsg properly with the following code:
alert(JSON.stringify(event.notification.aps.alert));
back to motoG, it works well to
good team work !
Eric
Hi there, I hv just upgraded from Cordova 3.7 to 4.1.1 to cope with the googlePlay notif.
I noticed that my code reading the notification msg doesn't work anymore.
any update ?
thks in advance
Eric
Hi Eric - Yes, it has been changed in libraries version 3.1
on the Push notification event try this JS code:
precode
alert(data.message);/code/pre
Hi Illya, thank you for your prompt response. Let me try this soon. Hv a good Sunday evening, Eric
Illya, good to know that. thks again.
I read a bit on the blog and found the following:
"Push Notification message
alert(data.message);
When the app is active and a Push Notification message arrives this event handle will be invoked and an alert will be shown. This is just a sample. In your app, you might want to invoke another action to process the notification."
Wld you be kind enough to tell me how (or where I can find) to remove this alert popping up at the middle of the window ?
thks in advance
Illya,
in fact, even though I didn't insert any handler on push notif event, I do get the alert msg popping up. basically I don't want this alert at the middle of the window. any idea how to block this alert before it pops up ? thks in advance, Eric
Sorry, I'm not sure that I'm getting your point here -- could you please illustrate what have you now in your app and what code you're using?
Illya,
what I understood with the 3.1 library is that on incoming notification from another device, if the app is active on foreground, then an alert pops up by default.
however, as soon as some code are set on "push notif" event, this code will supersede the default alert. that's what I wanted to do.
nevertheless, still I must find how to read the notif message itself with code in order to take action on it. I could do before with previous library, and have to look for it again with 3.1.
any advice ?
Eric
Eventually, I found the way to read the notif event's message with
JSON.stringify(data.message);
looks easier to implement than before ... good job !
however, it seems that even though the panel event handler is on a particular page, as soon as a notif comes in and the app is in the foreground with whatever page opened (different from the one having the panel event handler), then this notif panel event handler will be fired.
any reason to have such a broader scope ?
why don't this event handler is not only for the page ?
Eric