React-native-push-notification: how to get payload data from notification object

Created on 25 Feb 2017  路  8Comments  路  Source: zo0r/react-native-push-notification

Hi,
I am trying to pass a custom parameter (paylod), to remote push notification as follows:
{
"aps":
{
"alert": "News!",
"sound": "default"
"myurl" : "https://raywenderlich.com",
}
}

But when raised PushNotification.configure at componentDidMount, I am unable to see the data:

componentDidMount() {
PushNotification.configure({
onNotification: function(notification) {

       console.log(notification.data);


  },
});

}

Please advise

Thanks a lot

React Native version: 0.41
Platform: iOS
Operating System: MacOS

Stale

All 8 comments

Plus one

any fixes yet for this?

+1

Any word on this?

Unfortunately, without this feature the library is unusable(

anyone knows why this doesn't work?

you need to pass aditional parameter outside of "aps":

{
    "aps" : {
        "alert" : {
            "title" : "Game Request",
            "body" : "Bob wants to play poker",
            "action-loc-key" : "PLAY"
        },
        "badge" : 5
    },
    "acme1" : "bar",
    "acme2" : [ "bang",  "whiz" ]
}

For more details check Apple oficiall documentation:
https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings