Reputation: 3150
I have added push notification in my application which works fine.
I want to implement notifications such that, when a notification come on my device and I click on that notification, it should render me to that particular notification screen. currently I am using ios device.
I am using https://www.npmjs.com/package/react-native-push-notification
Upvotes: 1
Views: 1647
Reputation: 106
If you haven't add some more info for yourself in notification data payload which will be a pointer to yourself which screen do you want to render:
{
foreground: false, // BOOLEAN: If the notification was received in foreground or not
userInteraction: false, // BOOLEAN: If the notification was opened by the user from the notification area or not
message: 'My Notification Message', // STRING: The notification message
data: {
yourKey: 'value'
}, // OBJECT: The push data
}
Once you receive notification access that extra data field inside this function:
onNotification: function(notification) {
console.log( 'NOTIFICATION:', notification );
},
Once you have done that, push corresponding screen on a view stack or dynamically generate view inside render function or set initialRoute to screen you wanna show. I assume you are using navigator for multiple screens.
Upvotes: 3