Skip to content

getLastNotificationResponseAsync returns a half-empty object when the app is launched on Android #34523

@TuurDutoit

Description

@TuurDutoit

Minimal reproducible example

https://github.com/TuurDutoit/expo-notifications-example

What platform(s) does this occur on?

Android

Where did you reproduce the issue?

in a development build

Summary

Summary

When launching the app on Android, getLastNotificationResponseAsync returns a half-empty object like this:

{
  "actionIdentifier": "expo.modules.notifications.actions.DEFAULT",
  "notification": {
    "date": 0,
    "request": {
      "identifier": null,
      "content": {
        "data": {
          "anim_not_finish": false
        },
        "title": null
      },
      "trigger": {
        "type": "push",
        "channelId": null
      }
    }
  }
}

How to reproduce

I attached a repo you can use to reproduce the issue. It's essentially the bare-minimum template with expo-notifications installed. I added some logs so we can see the received data in the console.

To run it:

  1. Build and run the app: npm run android
  2. Close and reopen the app

Expected behavior: the last notification response logged to the console is null

Actual behavior: the data is an object that looks like a notification response, but misses most of the keys.

Logs

All the relevant logs, both from expo-notifications, as well the ones I added.

JS:

 LOG  LAST NOTIFICATION RESPONSE {
  "actionIdentifier": "expo.modules.notifications.actions.DEFAULT",
  "notification": {
    "date": 0,
    "request": {
      "identifier": null,
      "content": {
        "data": {
          "anim_not_finish": false
        },
        "title": null
      },
      "trigger": {
        "type": "push",
        "channelId": null
      }
    }
  }
}

Native logs (logcat):

01-28 13:36:19.229 10349 10349 I expo-notifications: ExpoNotificationLifeCycleListener.onCreate::
01-28 13:36:19.229 10349 10349 I expo-notifications: anim_not_finish: false
01-28 13:36:19.229 10349 10349 I TESTING : MainActivity.onCreate | intent.extras:
01-28 13:36:19.229 10349 10349 I TESTING : MainActivity.onCreate | - anim_not_finish
01-28 13:36:19.229 10349 10349 I TESTING : MainActivity.onCreate | /intent.extras
01-28 13:36:20.643 10349 10436 I expo-notifications: NotificationsEmitter.onNotificationResponseIntentReceived:
01-28 13:36:20.643 10349 10436 I expo-notifications: actionIdentifier: expo.modules.notifications.actions.DEFAULT
01-28 13:36:20.643 10349 10436 I expo-notifications: notification
01-28 13:36:20.643 10349 10436 I expo-notifications:   date: 0
01-28 13:36:20.643 10349 10436 I expo-notifications:   request
01-28 13:36:20.643 10349 10436 I expo-notifications:     identifier: (null)
01-28 13:36:20.643 10349 10436 I expo-notifications:     trigger
01-28 13:36:20.643 10349 10436 I expo-notifications:       type: push
01-28 13:36:20.643 10349 10436 I expo-notifications:       channelId: (null)
01-28 13:36:20.643 10349 10436 I expo-notifications:     content
01-28 13:36:20.643 10349 10436 I expo-notifications:       data
01-28 13:36:20.643 10349 10436 I expo-notifications:         anim_not_finish: false
01-28 13:36:20.643 10349 10436 I expo-notifications:       title: (null)

Note that, when the app is launched, there is 1 "extra" attached to the intent: anim_not_finish. I'm not sure where this comes from, I assume it's from my OS (I use a OnePlus Nord 2T 5G).

What I've been able to find so far

  • MainActivity.onCreate calls ReactActivityDelegateWrapper.onCreate
  • ReactActivityDelegateWrapper.onCreate calls all reactActivityLifecycleListeners here
  • That includes expo-notifications' ExpoNotificationLifecycleListener.onCreate here
  • If there are any extras attached to the intent, they are passed to mNotificationManager.onNotificationResponseFromExtras

Environment

expo-env-info 1.2.2 environment info:
    System:
      OS: macOS 14.6.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 20.13.1 - ~/.local/state/fnm_multishells/38834_1738067722227/bin/node
      Yarn: 1.22.22 - /opt/homebrew/bin/yarn
      npm: 10.5.2 - ~/.local/state/fnm_multishells/38834_1738067722227/bin/npm
      Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.16.2 - /opt/homebrew/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 24.2, iOS 18.2, macOS 15.2, tvOS 18.2, visionOS 2.2, watchOS 11.2
    IDEs:
      Android Studio: 2022.2 AI-222.4459.24.2221.9862592
      Xcode: 16.2/16C5032a - /usr/bin/xcodebuild
    npmPackages:
      expo: ~52.0.28 => 52.0.28 
      react: 18.3.1 => 18.3.1 
      react-native: 0.76.6 => 0.76.6 
    Expo Workflow: bare

Expo Doctor Diagnostics

Enabled experimental React Native Directory checks. Unset the EXPO_DOCTOR_ENABLE_DIRECTORY_CHECK environment variable to disable this check.
✔ Check package.json for common issues
✔ Check Expo config for common issues
✔ Check for app config fields that may not be synced in a non-CNG project
✔ Check for common project setup issues
✔ Check dependencies for packages that should not be installed directly
✔ Check for issues with Metro config
✔ Check npm/ yarn versions
✔ Check if the project meets version requirements for submission to app stores
✔ Check native tooling versions
✔ Validate packages against React Native Directory package metadata
✔ Check Expo config (app.json/ app.config.js) schema
✔ Check for legacy global CLI installed locally
✔ Check that native modules do not use incompatible support packages
✔ Check that packages match versions required by installed Expo SDK
✔ Check that native modules use compatible support package versions for installed Expo SDK

Didn't find any issues with the project!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions