Receiving Notifications works when the application is in the background/foreground, but not when the application is killed

Hello, I just learned about notifications in the expo, now I have successfully sent notifications and I have also managed to get data from the notifications I sent, the problem is, if the application is in background or foreground, addNotificationResponseReceivedListener is working properly (redirect to another page), but if I close the application, and I receive a notification, then I press the notification, the application opens but the addNotificationResponseReceivedListener function is not running, I try this in a standalone application

what i’m using:

“expo”: “~40.0.0”,
“expo-notifications”: “^0.9.0”,

here’s my example code in Home.js:

componentDidMount() {
    //another code..
    Notifications.addNotificationResponseReceivedListener(
      this._handleNotificationResponse
    );
  }

_handleNotificationResponse = (response) => {
    console.log(
      "CONSOLE FROM NOTIF: " +
        JSON.stringify(response.notification.request.content.data.from)
    );
    if (response.notification.request.content.data.from== "GEMASS") {
      this.props.navigation.navigate("goToPage", {
        //another code...
      });
    } else {
    }
  };

here’s my file tree:

App.js
Components
   - Home.js

and here’s my terminal looks like when i run on expo client:
image

can you guys help me? it means a lot :slight_smile:

Hey @sinarindoutama, what platform is this occurring on? Android/iOS/both?

Cheers,
Adam

Hallo @adamjnav, i use Android, sorry forgot to say which platform i use…

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