question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SDK 45.0.8 uselastnotificationresponse is not working when app killed/closed

See original GitHub issue

Summary

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:open
  • Created a year ago
  • Comments:17

github_iconTop GitHub Comments

3reactions
code4mukteshcommented, Oct 16, 2022

uselastnotificationresponse is not working when app is killed/closed with android real device(sdk46). Please fix it asap. @expo-community

0reactions
code4mukteshcommented, Nov 2, 2022

@expo-bot Any update?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expo notification doesnt fire method when app is killed/closed
The problem is that the useEffect() get called too late after the app has finished initializing. Therefore the listener is not added before ......
Read more >
Notifications - Expo Documentation
The expo-notifications provides an API to fetch push notification tokens and to ... When a notification is received while the app is running,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found