react-native-push-notification
react-native-push-notification copied to clipboard
Redirect to specific page when notification clicked
Question
In the notification action button, like for example, yes or no. How do you specifically redirect user to specific page in the app, when we use click the notification.
I want to redirect user to specific page in the app, for example, Notification page when the user click the notification
I get it now, I just need to do this when notification is triggered in the background:
Remote notification received object:
{
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: {}, // OBJECT: The push data or the defined userInfo in local notifications
}
Logic to navigate when notification is clicked:
// If foreground is true, set it to false so that user can't navigate when in the foreground
// If foreground is false, negate the value to true so the user can navigate -
// - to the page when notification was clicked
if (!notification.foreground) {
// Navigate to the page
}