FCM notification causes Expo built Android app to reload

Viewed 310

I have an expo app that I'm trying to add push notifications to. Everything works fine on both iOS and Android when running on actual devices pointing to Expo CLI running on my local machine.

Doing expo build:android and then running the app either from within the expo client app or installing the standalone app is when I see the issue. The app reloads when a push notification is received. If the app is in the foreground, the notification is not displayed, and the app just reloads as soon as the notification is received. If the app is in the background and the user taps the notification, the app opens and immediately reloads. When I say the app reloads I mean it looks like the app is being opened from a closed state (splash screen appears and initial page is displayed).

Since all works fine when connected to my local Expo CLI, I thought maybe production mode was what would trigger the issue, but things continue to work fine after switching my local Expo CLI to production mode.

Based on some other posts, maybe it has something to do with the android:launchMode expo managed apps are using. Since this isn't a detached app I don't think I have a way to change the launchMode that is being set in AndroidManifest.xml.

I've also tried adding this to my app.json under the android object, but still no luck.

"intentFilters": [
    {
        "action": "com.google.firebase.MESSAGING_EVENT"
    }
]

Some additional environment details:

  • Expo sdk: 37
  • Expo cli: 3.19.2
0 Answers
Related