-
Notifications
You must be signed in to change notification settings - Fork 374
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
[Android] Opening app with deep linking enabled via push notification containing Launch URL causes app to restart #1194
Comments
Howdy, Make sure you have Furthermore, please include your JS code for actually handling the opened event. Cheers |
Hello! I have included in my issue a zip file of the project, link here if it was missed out. There is no JS code handling the event. Full manifest below,
|
Howdy, |
Howdy, When you background it and bring it back, that has nothing to do with the deep link from the notification -- so if it is reloading, you're going to have to figure out why. But I don't see how that's OneSignal related. In terms of how to properly deep link and route your app to the correct screen, we recommend using additional data and routing to the correct screen using something like React Router, in this case. See the following documentation for information on how to parse the additional data payload and routing to the correct page/screen using that value: https://documentation.onesignal.com/docs/links#deep-linking-with-additional-data Cheers |
Hello @rgomezp, we are struggling with the same problem here We have Android DeepLinks configured and they are working properly in our app. We use de "Launch URL" param to send the DeepLink with the push and open the app with it. I would like to understand why we have a "Launch URL" but we cannot use it to launch the app. What are the pros of using additional data as you said above? For me, the docs are not clear about it. |
Hello @emilioheinz, I discovered a workaround for this issue. Under step 6 of my If your You will then have to handle for the prefix used in your Launch URL, which in this example is |
Hello @rgomezp, the re-launch happens only when the app is opened via a push notification containing a Launch URL. I don't know if this is React Native specific, or can also be reproduced on Android natively. A suggestion I would make is to include this in the documentation to warn developers of this. I'm okay to close this issue as there is a workaround. |
I don't think we can close it, since there is a issue and it still happening. |
@tingzhouu About your workaround, I think it is almost the same as using aditional data instead of launch url. |
I've figured something out. When we use additional data instead of Launch URL param and do this: OneSignal.setNotificationOpenedHandler(openedEvent => {
const { notification } = openedEvent
Linking.openURL(notification.additionalData.deepLink)
}) The same bug happens, I think it can be related to |
@emilioheinz , Furthermore, I would try to use something more like React Router for routing the user to the correct page after the app opens rather than the |
@rgomezp Yes, we did it with the additional data param, and passed the link to our NavigationService. Basically, we reused almost every code that we were running when the app was opened with a Link. It is working fine.
I'll try to test it and post here the results! |
Any update @emilioheinz ? |
I'll try to take a look at this before next Sunday 😄 |
@rgomezp Sorry for the delay. I've tested it in my application. Wrapping If there is anything else that I can help you to find a better solution, let me know! |
@emilioheinz , That's certainly interesting but it's just what I suspected. It looks like this is a React Native issue. Unfortunately this won't be fixed until RN solves the problem. However, you could always try the following workaround options:
Hope this helps. Closing the issue given the core problem is in the issue mentioned above. Cheers |
@rgomezp we are using the second option and it works fine. You said that it looks like it is a React Native issue. Could you please detail your thoughts? It may help us to open an issue on React Native repository. |
See the link in my previous comment for more details |
Nice, thank you! |
Hello @rgomezp, I'm still running into this issue and I'm starting to think it is related to how the Intent is started from the OneSignal's Android SDK. I think it's related to OneSignal because, as shows the GIF in the original post, the app is completely restarted when it comes in foreground, so this must not be related to React Native's Linking, it feels way more like an Android native thing. This is the Android logcat related to the app being bring in foreground: logcat. Also previously I had a workaround based on a native module that launched the app with a custom Intent, but lately it's starting to show some problems. This is the custom Intent I used (which solved the restart problem):
PS: As a temporary workaround I'm following @emilioheinz example by launching the URL from additionalData, but it feels dirty not to use the notification's launchUrl. Also it involves using a |
I'm having this exact same issue and I'm not using EDIT I also have app links enabled in my app, if I set |
In the react-native-onesignal 4.3.2 Release we changed the Android Activity launch implementation to use Notification Reverse Activity Trampolining. This may effect how the app is started and resumed. It possible this could have fixed this issue but it hasn't been tested to confirm. |
For those still seeing this issue, please upgrade to at least 4.3.2 as mentioned in the above comment. Cheers |
I have upgraded to |
Worth mentioning that if you still need to use the Launch URL for backward compatibility, you can add https://documentation.onesignal.com/docs/links#example-suppress-launch-urls |
@jbernhardt23 , |
This may be resolved after the following PR OneSignal/OneSignal-Android-SDK#1598 lands into a new release of react-native-onesignal |
Closing for now. Feel free to reopen if the issue persists. |
This issue is still happening any workaround please ? |
Description:
I have an app with deep linking enabled, following react-navigation's instructions here by adding an additional
intent-filter
inAndroidManifest.xml
.The app is not running in the background. Opening the app via a push notification containing Launch URL will cause the app to restart when I go to the home screen and open the app again, meaning that the app goes from running in the background to running in the foreground.
Emphasizing on how to recreate this:
AndroidManifest.xml
Environment
OneSignal React-Native SDK version:
4.0.6
React-Native version:
0.64.0
SDK added using:
yarn
Devices used: Pixel 4a, Samsung Galaxy S10+
Steps to Reproduce Issue:
npx react-native init abcdefg
yarn add react-native-onesignal
and follow standard installation instructions hereandroid/app/src/main/AndroidManifest.xml
with below snippet to enable deep linkingabcdefg://
orabcdefg://anythinggoes
.Repeat steps 8 and 9 to reproduce the behavior.
Expected behavior: App to open and nothing else happens
Actual behavior: App opens and restarts
Anything else:
Example Project: example_project.zip
Screen Recording: video file
The text was updated successfully, but these errors were encountered: