zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.76k stars 2.06k forks source link

how to get payload data from notification object #377

Closed adriancuco closed 3 years ago

adriancuco commented 7 years ago

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

jqn commented 7 years ago

Plus one

nullpointer07 commented 7 years ago

any fixes yet for this?

nazywamsiepawel commented 7 years ago

+1

Diego-F-Aguirre commented 6 years ago

Any word on this?

danilValeev commented 6 years ago

Unfortunately, without this feature the library is unusable(

ianpogi5 commented 6 years ago

anyone knows why this doesn't work?

aramvr commented 5 years ago

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

github-actions[bot] commented 4 years ago

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.