Languages

Menu
Sites
Language
How to get appData payload for stored push notifications?

If my webapp receives a bunch of push notifications while it is not running, I can retrieve data about them like this-

var notifications = tizen.notification.getAll();
for( var i=0; i < notifications.length; ++i )
{
    //get info from notification -
    console.log(notifications[i].title);    //etc
    var appControl = notifications[i].appControl;
    console.log(appControl.operation);      //fine, data as expected
    console.log(appControl.data.length);    //always zero length array...?
}

However, there is never any data in the appControl.data field, where I expect to find the appData message body(payload) from the push notification. If I launch the application by pressing a particular notification, the appControl.data is present -

var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl();
var appControl = reqAppControl.appControl;
console.log( appControl.data.length);   //non-zero, appData message payload is stored in key/values

The only way it seems I can get the appData message payload for all the notifications, is by relying on the user to press every one, which is not ideal; with the native API I can easily find the payload for all the stored notifications.

Has anyone else had more luck with this?

 

 

 

 

Responses

3 Replies
talari praveen kumar

Hi

When the application is running the I am able to retrieve message body but when application is in background i am getting notifications but not able to retrieve the message body for this I have raised a bug. Please follow the below link for more updates

https://bugs.tizen.org/jira/browse/TDIST-411?filter=-2

Alan Savage

Ok thanks for the info (although that link didn't work for me).

Strangely enough, if I post a notification from within my app and attach a payload, the above code works fine, and I can see the appData when I query the list of notifications.

It is only when the os creates the notification when the app is not running, that the appControl.data field is invalid, when queried from the notifications list.

Matt Alonso

Looks like the original link has a filter on it.  The bug report can be accessed here https://bugs.tizen.org/jira/browse/TDIST-411