expo: Notifications don't open app since SDK45 (Android)

Summary

I upgraded a managed app from SDK44 to SDK45 and now, when a notification is received while the app is in background, touching the notification in Android doesn’t open the app as it used to with SDK44. The listener is called and executed, but the app UI is not shown.

This happens both in Expo GO Android and in the native Android app. When the same code is run in Expo GO Apple it correctly opens the app.

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

SDK Version (managed workflow only)

45

Environment

expo-env-info 1.0.3 environment info: System: OS: Linux 5.17 Pop!_OS 22.04 LTS Shell: 5.1.16 - /bin/bash Binaries: Node: 16.14.2 - /usr/bin/node npm: 8.5.0 - /usr/bin/npm npmPackages: expo: ^45.0.0 => 45.0.4 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 npmGlobalPackages: eas-cli: 0.52.0 expo-cli: 5.4.4 Expo Workflow: managed

Reproducible demo

This is the listener:

Notifications.addNotificationResponseReceivedListener(response => {
console.log(`received notification "${response.notification.request.content.title}"`);
});

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 9
  • Comments: 39 (15 by maintainers)

Commits related to this issue

Most upvoted comments

i’m sorry that we might take longer time to release the fix. i found a regression issue from my fix. will try to find a solution and anyway, will keep the status updates here.

sorry i was busy for next sdk development and didn’t get a chance to look it this week. will try to do it these two days.

Nothing personal Kudo, but this order of priorities is one of the biggest hindrances of Expo for the adoption in business environment. You’re often too concentrated on delivering timely “best new things” and neglecting making existing stuff work right. Expo SDK45 was released almost 2 months ago and was completely unusable for anyone employing notifications on Android. It was probably never tested with current Android OS version before release. What’s worse, this bug and its regressions (still open) are not even mentioned in the release notes known problems, making anyone upgrading their apps from previous SDK having to find it out the hard way.

published expo-notifications@0.15.3 to address the issues. please try to upgrade expo-notifications and let us know if it still not works for you. thanks!

i’m working on it. both for new expo-notifications packages as well as new expo go build. will update here once the new versions are ready.

@jnoleau good catch. to fix the trampoline issue, the fix changed much in the way to send notifications, so the issue you reported should be a regression. i’ll take a look this week. thanks!

@jnoleau we just publish expo-notifications@0.15.4 to address the issue. hopefully this one fixes all the issues. thanks!

@Kudo Thanks a lot for your help with this, I’m testing your patch right now and for now it’s working perfectly 🎉 I’ll update if I see any other issue

@rrufus there is still a case i missed from push notifications. i’m working on it. hopefully we can release it soon.

Thanks, @Kudo for all the work. I face some problems with a Samsung Galaxy when I click a notification. When I extracted the bug report, here’s what I found:

08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: FATAL EXCEPTION: main
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: Process: com.snehanshu.motorsaarthicustomerapp, PID: 27623
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.snehanshu.motorsaarthicustomerapp/expo.modules.notifications.service.NotificationForwarderActivity}: java.lang.IllegalArgumentException: notification and action should not be null
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4035)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4201)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2438)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:226)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:313)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:8663)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: notification and action should not be null
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at expo.modules.notifications.service.NotificationsService$Companion.createNotificationResponseBroadcastIntent(NotificationsService.kt:16)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at expo.modules.notifications.service.NotificationForwarderActivity.onCreate(NotificationForwarderActivity.kt:2)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:8290)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:8270)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4009)
08-02 00:56:23.231 10552 27623 27623 E AndroidRuntime: 	... 12 more

I found the code that throws this resides here: https://github.com/expo/expo/blob/41efff607c27f229c3f008ddda5977b9b433d7d6/packages/expo-notifications/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt#L480

Any idea why this may happen? When the app is either background or killed, clicking the notification does nothing. When the app is on foreground, clicking the notification crashes the app. This happens both on Expo Go and standalone apk.

Hi. Have you resolved this issue? I have the sameissue too. Is the device Samsung with Android 11?

Facing similar issues, did this issue get resolved for Samsung galaxy.

Have you found any solution ? Facing the same issue

@edjiang Yes, you need to release a new binary since the changes was applied in the native code, see the PR (https://github.com/expo/expo/pull/17974/files)

@amagnolo i am apologizing for this problem and agreeing that is critical. that’s why i am trying to investigate and propose a fix during the weekend. notifications and android intents are much complicated, so we missed some test cases when released sdk 45. especially in android 12 introduced lot of breaking changes, we didn’t notice every edge cases for each expo modules. the root cause of useLastNotificationResponse issue is actually from multiple pendingIntent and the latest one will overwrite the previous one.

anyway this is the fix i’m trying to propose: https://gist.github.com/Kudo/b8d6a7e75d951fa6652fe255c2068bd0 if someone has the expertise for android to review my fix or has a chance to test it by patch-package before we landing this fix, in case i missed some edge test cases again, i am super appreciated for that. i will organize a formal pr, merge and release a fix tomorrow. thanks and apologies again.

sorry i was busy for next sdk development and didn’t get a chance to look it this week. will try to do it these two days.

I confirm that the original issue is now solved. Good job!