Push Notification docs ("Usage" section)

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:

  1. 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?
  2. On the remove statement I think that “.current” is missing in both cases:
return () => {
      Notifications.removeNotificationSubscription(notificationListener);
      Notifications.removeNotificationSubscription(responseListener);
    };

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.