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));
}