expo: addNotificationResponseReceivedListener or useLastNotificationResponse is not firing when app is killed

Summary

Both useLastNotificationResponse hook and addNotificationResponseReceivedListener isn’t firing when my expo app is killed. Working only in background and foreground. My expo-notifications package is up-to-date : “^0.9.0”.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android, iOS

SDK Version (managed workflow only)

40.0.1

Environment

Expo CLI 4.1.6 environment info: System: OS: macOS 10.15.5 Shell: 3.2.57 - /bin/bash Binaries: Node: 14.8.0 - ~/.nvm/versions/node/v14.8.0/bin/node npm: 6.14.7 - ~/.nvm/versions/node/v14.8.0/bin/npm SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 Xcode: 12.4/12D4e - /usr/bin/xcodebuild npmPackages: expo: ^40.0.1 => 40.0.1 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 react-native-web: ~0.13.12 => 0.13.18 npmGlobalPackages: expo-cli: 4.1.6 Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

Notifications.setNotificationHandler({
	handleNotification: async () => ({
		shouldShowAlert: true,
		shouldPlaySound: false,
		shouldSetBadge: false,
	}),
});

Notifications.addNotificationResponseReceivedListener((response) => {
  console.log("received response!", response);
});

const handlePush = async ({ notification }) => {
	console.log("navigate");
}


export default function App() {


	const lastNotificationResponse = Notifications.useLastNotificationResponse();

	React.useEffect(() => {
		console.log(lastNotificationResponse);
					if (lastNotificationResponse && lastNotificationResponse.actionIdentifier === Notifications.DEFAULT_ACTION_IDENTIFIER) {
					handlePush(lastNotificationResponse);
			}
	}, [lastNotificationResponse]);

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 20 (4 by maintainers)

Most upvoted comments

I still experienced this issue on SDK 44 (managed)

I still experienced this issue on SDK 44 (managed)

Were you able to fix this? Can someone confirm if this is fixed March 2023?

The issue is still there SDK 42 (managed ), using the addNotificationResponseReceivedListener or the new hook even if it’s the first line in App.js , same results , However sometimes it works .