react-native-notifications: Can't get an interactive action response when iOS app is in dead state
Version: react-native-notifications@3.4.2 System: iOS
- When the app is not dead (foreground, background) and I tap on one of the actions in notification, then
registerNotificationOpenedcallback is called and I getactionResponsethere - When the app is dead and I tap on notification (not on action), I get
notificationfromNotifications.getInitialNotification() - When the app is dead and I tap on one of the actions in push notification,
Notifications.getInitialNotification()returnsundefinedandregisterNotificationOpenedcallback is not called
import { Notifications, NotificationAction, NotificationCategory } from 'react-native-notifications';
Notifications.registerRemoteNotifications();
Notifications.events().registerNotificationOpened((_notification: Notification, completion, actionResponse) => {
// this callback is called only when app is not dead
completion();
});
let acceptAction = new NotificationAction('ACCEPT_ACTION', 'foreground', 'Accept', true);
let skipAction = new NotificationAction('SKIP_ACTION', 'foreground', 'Skip', true);
let someCategory = new NotificationCategory('SOME_CATEGORY', [acceptAction, skipAction]);
Notifications.setCategories([someCategory]);
// This will be undefined when the app is dead and I tap on one of the actions in push notification
const notification = await Notifications.getInitialNotification();
Will appreciate any comments. Thanks!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 25
@ninjz Thank you for your advice. But sadly it doesn’t work for me. Neither with
Notifications.registerRemoteNotifications(), also not withPushNotificationIOS.requestPermissions(). Seems like I have to dig deeperEDIT: Nevermind, it worked after a fresh pod install, including the approach by mkizesov. Thank you very much 😃
I’m facing the same issue right now. When pressing an action on the iPhone everything works fine and registerNotificationOpened() gets raised. But when clicking on the action on an AppleWatch “nothing” happens. The app get’s started (background), but the event doesn’t raise.