In the documentation example ther is a line that subscribes to respond to received notifications:
// This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed)
responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
console.log(response);
});
It says it will fire even when the app is backgrounded or killed.
2 issues:
- Why do we remove the lisener in the unmount? I get that we don’t want to subscribe multiple time but how will it work when app is not foreground if we remove listener?
- On the remove statement I think that “.current” is missing in both cases:
return () => {
Notifications.removeNotificationSubscription(notificationListener);
Notifications.removeNotificationSubscription(responseListener);
};