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

[ANDROID] Linking.getInitialURL() returns null after exiting the app with back button and using deep linking again (only in production!) #15961

Closed
ferrannp opened this issue Sep 15, 2017 · 2 comments
Labels
Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@ferrannp
Copy link
Contributor

ferrannp commented Sep 15, 2017

Is this a bug report?

Yes.

Environment

  1. react-native -v: 0.46.4
  2. node -v: 8.4.0
  3. npm -v: 5.3.0
  4. yarn --version: 0.27.5
  • Target Platform: Android
  • Development Operating System: macOS

Steps to Reproduce

Configure your app to receive deep linking links as explained here: https://facebook.github.io/react-native/docs/linking.html.

My native code looks like:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="https"
          android:host="some-url.com"
          android:pathPrefix="/some-prefix" />
</intent-filter>

I also set the Android Activity to singleTask.

On the JS code:

componentDidMount() {
  Linking.getInitialURL().then((url: string) => {
    if (url) {
      this._handleLinking(url);
    }
  });
}

Expected Behavior

  1. URL is not null when handling deep linking. I am using the command:
$ adb shell am start
        -W -a android.intent.action.VIEW
        -d "example://gizmos" com.example.android

Actual Behavior

Development

  • I kill the app (manually removing it from apps), I ran the adb command, url is not null and deep linking is ok
  • I open the app, I kill the activity with the back button, I ran the adb command, url is not null and deep linking is ok

Production

  • I kill the app (manually removing it from apps), I ran the adb command, url is not null and deep linking is ok
  • I open the app, I kill the activity with the back button, I ran the adb command, url is null so I cannot handle the deep linking

From Logcat:

09-15 18:18:52.262 675-686/system_process I/ActivityManager: START u0 {act=android.intent.action.VIEW dat=https://some-url.com/... flg=0x10000000 pkg=com.myapp cmp=com.myapp/.MainActivity} from uid 0 on display 0
09-15 18:18:52.386 8191-10955/com.myapp I/ReactNativeJS: Running application "MyApp" with appParams: {"rootTag":11}. __DEV__ === false, development-level warning are OFF, performance optimizations are ON
09-15 18:18:52.393 8191-10955/com.myapp I/ReactNativeJS: getInitialURL null

As you can see Intent has data but the console.log inside getInitialURL shows null as url.

It looks like an issue which the fact that even that I kill the activity with back button, JS bundle is not destroyed till it passes some time. However, I don't understand why the behavior is different in development than in production. The correct behavior is the development one though.

Some debugging

Race condition somewhere? Is it possible than in this case componentDidMount it's called before the actual activity gets created?

Reproducible Demo

Can't do it in Expo. I'll try to write something I can share.

@ferrannp ferrannp changed the title [ANDROID] Linking.getInitialURL() returns null after exiting the app with back button and re-opening the app (only in production!) [ANDROID] Linking.getInitialURL() returns null after exiting the app with back button and using deep linking again (only in production!) Sep 15, 2017
@radko93
Copy link
Contributor

radko93 commented Sep 18, 2017

@facebook-github-bot label Android

@facebook-github-bot facebook-github-bot added Android Ran Commands One of our bots successfully processed a command. labels Sep 18, 2017
@stale
Copy link

stale bot commented Nov 17, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 17, 2017
@stale stale bot closed this as completed Nov 24, 2017
@facebook facebook locked and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

3 participants