react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

how to get payload data from notification object

Open adriancuco opened this issue 9 years ago • 8 comments

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

adriancuco avatar Feb 25 '17 16:02 adriancuco

Plus one

jqn avatar Mar 10 '17 00:03 jqn

any fixes yet for this?

nullpointer07 avatar Mar 10 '17 11:03 nullpointer07

+1

nazywamsiepawel avatar Aug 31 '17 13:08 nazywamsiepawel

Any word on this?

Diego-F-Aguirre avatar Dec 27 '17 15:12 Diego-F-Aguirre

Unfortunately, without this feature the library is unusable(

danilValeev avatar Feb 05 '18 06:02 danilValeev

anyone knows why this doesn't work?

ianpogi5 avatar Aug 16 '18 05:08 ianpogi5

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

aramvr avatar Nov 27 '18 08:11 aramvr

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.

github-actions[bot] avatar Oct 28 '20 00:10 github-actions[bot]