handling pushnotifications when app is closed

Please provide the following:

  1. SDK Version: 37
  2. Platforms(Android/iOS/web/all):Android /Ios
 componentDidMount() {
    this.registerForPushNotificationsAsync();
    this._notificationSubscription = Notifications.addListener(this._handleNotification);
  }
  _handleNotification = notification => {
    Vibration.vibrate();
    console.log(notification);
    console.log("hello")
    this.setState({ notification: notification });
  };

When the app is foregrounded the handle function is executed and the console.log is executed but when the app is closed the handle function is not executed at all?
Can anyone help?

1 Like

Take a look here.

  useEffect(() => {
    Notifications.addListener(handleNotification);
  }, []);

  const handleNotification = (notification) => {
    Vibration.vibrate();
    console.log(notification);
  };

unfortunately On Android when the app is foregrounded or in backgrounded the listener works but when the app is closed the listener does not work at all

@mkhoussid

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