distriqt / airnativeextensions

DEPRECATED: Original repository of the distriqt native extensions and is no longer maintained. Please see our site for the latest ANEs
https://airnativeextensions.com
2 stars 0 forks source link

push notification question #158

Closed wztechno closed 10 years ago

wztechno commented 10 years ago

Hello

I want to be able to save the notification sent to my phone as follow:

title : message title content: the actual message

so I need to have access to all the different payloads delivered by the notification, I understand that this can be achieved inside the "pn_notificationHandler" function in the example code, but what specific code allows me to trace the message alone from the notification (something like trace(event.data.message))

thank you in advance!

marchbold commented 10 years ago

Hi,

The payload of the notification is delivered with the event in the data variable, this is generally json so you can do something like the following:

try
{
    JSON.parse( event.data );
}
catch (e:Error)
{
}

If you wish to just store the data, the PushNotificationEvent.data is just a String.

http://docs.airnativeextensions.com/pushnotifications/docs/com/distriqt/extension/pushnotifications/events/PushNotificationEvent.html