Please provide the following:
Expo CLI 3.27.14 environment info:
System:
OS: Linux 5.4 Ubuntu 18.04.4 LTS (Bionic Beaver)
Shell: 5.4.2 - /usr/bin/zsh
Binaries:
Node: 12.18.2 - /usr/bin/node
Yarn: 1.22.4 - /usr/bin/yarn
npm: 6.14.5 - /usr/bin/npm
npmPackages:
expo: ^40.0.0 => 40.0.0
“expo-notifications”: “~0.8.2”,
react: 16.13.1 => 16.13.1
react-dom: 16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz => 0.63.2
npmGlobalPackages:
expo-cli: 3.27.14
Expo Workflow: managed
When app is foreground and if notification send from expo push notification tool.
addNotificationReceivedListener event is triggered successfully.
if app is in background and if notification send from expo push notification tool. after tapping on notification, addNotificationResponseReceivedListener event is triggered successfully.
but if app is closed and notification send from expo push notification tool. after tapping on notification, addNotificationResponseReceivedListener event is not triggering.
import * as Notifications from "expo-notifications";
constructor(props) {
super(props);
this.notificationListener = React.createRef();
this.responseListener = React.createRef();
}
componentDidMount() {
const { authStatus, userResponse } = this.props.user;
if (
Object.keys(userResponse).length > 0 &&
userResponse.constructor === Object &&
authStatus === "logged"
) {
this.notificationListener.current = Notifications.addNotificationReceivedListener(
(notification) => {
console.warn("notification ==>>", notification);
}
);
this.responseListener.current = Notifications.addNotificationResponseReceivedListener(
(response) => {
console.warn("response ==>>", response);
}
);
}
}
componentWillUnmount() {
Notifications.removeNotificationSubscription(this.notificationListener);
Notifications.removeNotificationSubscription(this.responseListener);
}