SDK 45.0.8 uselastnotificationresponse is not working when app killed/closed
See original GitHub issueSummary
On real android device, tap to notification is not navigating to specific screen. Did some debugging and found uselastnotificationresponse is not called when app is in close/ killed.
Note: It is working when app in foreground.
“expo-notifications”: “~0.15.4”
What platform(s) does this occur on?
Android
Environment
expo-env-info 1.0.5 environment info: System: OS: Windows 10 10.0.19044 Binaries: Node: 14.17.5 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD npm: 6.14.14 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 2020.3.0.0 AI-203.7717.56.2031.7583922 npmPackages: expo: ^45.0.8 => 45.0.8 react: 17.0.2 => 17.0.2 react-dom: 17.0.2 => 17.0.2 react-native: 0.68.2 => 0.68.2 react-native-web: 0.17.7 => 0.17.7 Expo Workflow: bare
Minimal reproducible example
Use Firebase Cloud Messaging(FCM) notification to send notification Click on notification when app is closed Use this code to handle click:
React.useEffect(() => {
if (
lastNotificationResponse &&
lastNotificationResponse.actionIdentifier === Notifications.DEFAULT_ACTION_IDENTIFIER
) {
try {
const req = lastNotificationResponse.notification.request;
let params = {};
var content;
if (req.trigger.remoteMessage) {
content = req.trigger.remoteMessage;
} else {
content = req.content
}
if (content.data.navigation_screen) {
params[content.data.navigation_param] = content.data.navigation_param_value;
props.props.navigation.navigate(content.data.navigation_screen
, params);
} else {
props.props.navigation.navigate("Notifications");
}
} catch (e) {
Logger.Error(e, "TapHandler");
}
}
}, [lastNotificationResponse]);
Issue Analytics
- State:
- Created a year ago
- Comments:17
uselastnotificationresponse is not working when app is killed/closed with android real device(sdk46). Please fix it asap. @expo-community
@expo-bot Any update?