Hello guys, what is the action when user tries to click on arrived notification? How to handle only click on the notification when app is live/foreground?
Simple case:
Click on notification and redirect user to another page in app. (or open app and do the same thing)
Thanks!
+1 Would be so great, it's actually the only thing I need
+1
@zo0r or @Gp2mv3 any ideas if this is possible or something that is planned?
+1
Hey Guys! the notification has a boolean property called userInteraction, this means the user pressed on the notification.
onNotifictaion(notificication) {
....
if(notification.userInteraction) {
// Redirect wherever you want
}
}
Anyone get any solution to manage click event and redirect to a particular screen?
@chukitow unfortunately userInteraction work if a user clicks on Notif in background.
For handler on click event on iOS, you can register next handler:
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
// The user launched the app.
if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) {
NSMutableDictionary *newUserInfo = [[NSMutableDictionary alloc]initWithDictionary:response.notification.request.content.userInfo];
[newUserInfo setObject:[NSNumber numberWithBool:TRUE] forKey:@"userInteraction"];
[RNCPushNotificationIOS didReceiveRemoteNotification:newUserInfo];
}
}
and check this native event in your js event onNotification. For example:
onNotification = (notification) => {
...
if (notification.data.userInteraction) {
navigate(ROUTE_NAME);
}
...
};
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.
Most helpful comment
@chukitow unfortunately
userInteractionwork if a user clicks on Notif in background.For handler on click event on iOS, you can register next handler:
and check this native event in your js event
onNotification. For example: