expo-notification not working when app is closed

when app is closed then sent the notification via the Expo Notifications service. notification show in device but when tapping on notification

 [addNotificationReceivedListener 
addNotificationResponseReceivedListener]

none of these two listeners triggerd.

when app is in Foreground or in background it’s working fine. but problem occurs when app is closed.

expo sdk :- 39
“expo-notifications”: “~0.7.2”,
Platform :- Android

import * as Notifications from "expo-notifications";

constructor(props) {
      super(props);
      this.notificationListener = React.createRef();
      this.responseListener = React.createRef();
    }

    componentDidMount() {
      this.notificationListener.current = Notifications.addNotificationReceivedListener(
          (notification) => {
            this._handleNotification(
              notification.request.content,
              "foreground"
            );
          }
        );

        this.responseListener.current = Notifications.addNotificationResponseReceivedListener(
          (response) => {
            this._handleNotification(
              response.notification.request.content,
              "background"
            );
          }
        );
    }
    componentWillUnmount() {
      Notifications.removeNotificationSubscription(this.notificationListener);
      Notifications.removeNotificationSubscription(this.responseListener);
    }
_handleNotification = (notification, type) => {
   Alert.alert(JSON.stringify(notification));
}

Hi @026binit, have you figured out any solution?
My environment is just like yours, and I face the same issue :frowning:

Same thing here… only on Android (on iOS it works).

It depends on Android Phone. In my case I need to go to app’s settings and turn on allow running in background. Some devices block notifications.

It worked for me with the previous notification API and I didn’t have to touch anything on the device. The truth is that this makes it difficult to generate certain actions that are linked to the notification

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