ios
ios copied to clipboard
Cannot access local notification payload after clicking on notification action button
I have followed official documentation and added actionable notification to the IOS app. Buttons are showing and If the app is in foreground or background, when button is pressed, I can handle the notification data and process it. My problem is that when the app is killed and local notification is received, after clicking on action button the app is launched but I cannot see anywhere the data from the notification. No event listener triggered or anything that can lead me to notification's content. I've also debug the native code in XCode and when notification is received and the following code is triggered:
` // Required for localNotification event
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { [RNCPushNotificationIOS didReceiveNotificationResponse:response]; } `
But nothing is passed in React-Native code. I've also tried to use getInitialNotification() but it always returns null. How can I access notification from cold start and determine which button is pressed?
I am using
- React-Native 0.61.5
- push-notification-ios 1.7.1
@Joro-Popov Thanks for raising the issue. At the moment I don't think it is possible to get the notification content from cold start with the new notificationRequest. I understand that this is essential part of the notification, and will look into it for the next update.
Thank you @Naturalclar . I guess we should wait for the next release
Same problem here (tested only for remote notifications). Is there a workaround to get the data ?
I am also facing the same issue.
I am using
"react": "16.13.1",
"react-native": "0.63.3",
"@react-native-community/push-notification-ios": "^1.7.3",
"react-native-push-notification": "^6.1.3"
Does anyone have a solution for this?
I've implemented a workaround for my case which is not the best solution probably but it is working for the purposes of my app. What I've saw is that the notification is processed on the native side and the data is there....the pressed action, title, message and so on. I've parsed the needed data into strings and I've saved it in the async storage. That way, when the JS code starts, I will have the data saved and all I have to do is get it from the storage. This is my implementation:
I've implemented a workaround for my case which is not the best solution probably but it is working for the purposes of my app. What I've saw is that the notification is processed on the native side and the data is there....the pressed action, title, message and so on. I've parsed the needed data into strings and I've saved it in the async storage. That way, when the JS code starts, I will have the data saved and all I have to do is get it from the storage. This is my implementation:
@Joro-Popov can you please share your code here or steps to implement code for actionable notification
@Joro-Popov When you click on the notification action while the app is terminated, do you launch the app to the foreground or to the background? I'm having issues getting this to work when launching it into the background to do some processing. Thanks
@Joro-Popov are you using PushNotificationIOS.addNotificationRequest or just PushNotification.localNotification? (I'm supposing you're also using react-native-push-notification)