Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expo SDK 50 - Foreground notifications cause app to reload #550

Open
robwalkerco opened this issue Jan 23, 2024 · 7 comments
Open

Expo SDK 50 - Foreground notifications cause app to reload #550

robwalkerco opened this issue Jan 23, 2024 · 7 comments

Comments

@robwalkerco
Copy link

❗For how-to inquiries involving Airship functionality or use cases, please
contact (support)[https://support.airship.com/].

Preliminary Info

What Airship dependencies are you using?

"@ua/react-native-airship": "^17.1.1",
"airship-expo-plugin": "^1.1.0",

What are the versions of any relevant development tools you are using?

"expo": "^50.0.2",

Report

What unexpected behaviour are you seeing?

When I receive a notification and the app is active and in the foreground, then tapping the app is causing the app to be reloaded.

I suspect this is because of something working differently either in React Native 0.73 or in Expo SDK 50

What is the expected behaviour?

When I receive a notification and the app is active and in the foreground, then I expect that tapping the notification allows the app to handle the notification in the foreground.

What are the steps to reproduce the unexpected behaviour?

I'm replicating this by upgrading from a Expo SDK 49 to Expo SDK 50 project

Do you have logging for the issue?

No

@rlepinski
Copy link
Collaborator

What OS are you testing on?

@robwalkerco
Copy link
Author

What OS are you testing on?

Oh, sorry. That is replicated on Android 14.

I have not tested on iOS

@rlepinski
Copy link
Collaborator

This could be old Android knowledge that I need to forget, but I remember a similar issue when launching a notification if the app was started through AS/adb. If you start the app that way, kill it, then launch it normally it would have the proper restore launch intent behavior. Could you double check that? If its still happening I will need the manifest to see if I can make sense of whats going on

@robwalkerco
Copy link
Author

if the app was started through AS/adb

That could be it.
I'll test tomorrow morning and confirm either way

@robwalkerco
Copy link
Author

robwalkerco commented Jan 24, 2024

I've tested again and found the following:

When using the expo-dev-client and building and running the development app, the app reloads each time I tap on a notification in the foreground.

If I build and sign the app, then tapping a foreground notification does not cause the app to reload.

There are some changes between Expo 49 and Expo 50 regarding how the app is launched, summarised in the change log - https://expo.dev/changelog/2024/01-18-sdk-50#other-highlights (See the 4th point regarding expo-dev-client)

I have also been able to restore the original behaviour by setting the launchModeExperimental property of the expo-dev-client plugin to launcher.

module.exports = {
  expo: {
    ...,
    plugins: [
      ...,
      [
        'expo-dev-client',
        {
          ios: {
            launchModeExperimental: 'launcher',
          },
          android: {
            launchModeExperimental: 'launcher',
          },
        },
      ]
    ]
  }
}

With this change, the original launcher behaviour is used - Opening the app from a push notification requires selecting the bundler to use from the expo dev client menu, but tapping a notification from the foreground is handled in the foreground 🎉

I can consider my problem fixed now, but it would be great if there is a way to resolve this issue without having to specify the launchModeExperimental option. If this cannot be changed, then perhaps a note in the documentation would be helpful for others having the same issue.

@MaxInMoon
Copy link

@robwalkerco thank you so much man

@robwalkerco
Copy link
Author

robwalkerco commented Jun 7, 2024

@robwalkerco thank you so much man

You're welcome @MaxInMoon.

For anyone running into this issue, the config property was renamed in the latest Expo SDK to launchMode (docs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants