Hey there!
I am trying to pass data to a localNotifcation and receive it in onNotification when i have clicked on it:
My code at presents:
PushNotification.localPushNotification({
title : 'Title',
message: 'Message',
data : {
venueName: venue.name,
venueType: venue['@type'],
venueId : venue['@id'],
type : 'venue'
}
});
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister: function (token) {
console.log('NOTIFICATIONTOKEN:', token.token);
Helper.registerDevice(token.token);
},
// (required) Called when a remote or local notification is opened or received
onNotification: function (notification) {
const {dispatch, User} = context.props;
let type = notification.type;
if (notification.userInteraction) {
switch (notification.type) {
case 'venue':
alert('Go to Venue View')
break;
}
}
},
popInitialNotification: true
});
I can pass the data to my localNotifcation, but when i have clicked on the PushNoti, and debugging onNotification, then there is no data. Simply this is what i get:

Any ideas?
What is the issue that you are facing? Are you not able to access the data in the notification? Can you try console.log the notification to see what you got back?
@varungupta85 The image where displayed shows my notification object within my onNotification function. There is no notifcation.data which i need and which i have passed to my localNotification when created...

@BigPun86 Can you try showing the notification like this and check if you get the data in the notification. Essentially, don't wrap it in data
PushNotification.localPushNotification({
title : 'Title',
message: 'Message',
venueName: venue.name,
venueType: venue['@type'],
venueId : venue['@id'],
type : 'venue'
});
I am using it this way and I am able to get the data in notification handler.
@varungupta85 You are the best. But why this won麓t work when i give him an object?
@BigPun86 Thanks :) I think it is not working with an object due to the way the object is converted to ReadableMap and then back to JS object in the native bridge code. I think the conversion to ReadableMap is not able to handle nested object but that is just my guess.
Hi is this topic about android or IOS? Is there a way to pass data on android? Thanks
@mcmatan It was an Android issue
@BigPun86 Thanks!
Closing due to inactivity. Please reopen if this is still an issue for you.
Most helpful comment
@BigPun86 Can you try showing the notification like this and check if you get the data in the notification. Essentially, don't wrap it in
dataI am using it this way and I am able to get the data in notification handler.