Skip to content
Permalink
Browse files

Make Linking.getInitialURL works properly even if current activity is…

… not initialized (#24748)

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

As the issue says, it seems that `currentActivity` is null in [IntentModule#getInitialURL](https://github.com/facebook/react-native/blob/1e8f3b11027fe0a7514b4fc97d0798d3c64bc895/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java#L50). So I used the `InteractionManager` to wait until current activity to finish initializing.

[Android] [Fixed] - In `Linking.getInitialURL` method, use the `InteractionManager` to wait for the current activity to finish initializing.
Pull Request resolved: #24748

Differential Revision: D15258046

Pulled By: cpojer

fbshipit-source-id: 0ec1c873766ae90955d47e5e023556eb6c5d5fbb
  • Loading branch information...
mu29 authored and facebook-github-bot committed May 8, 2019
1 parent 16e4971 commit c802d0b757912358d703d4d8a114073377a905b9
Showing with 6 additions and 1 deletion.
  1. +6 −1 Libraries/Linking/Linking.js
@@ -13,6 +13,7 @@
const NativeEventEmitter = require('NativeEventEmitter');
const NativeModules = require('NativeModules');
const Platform = require('Platform');
const InteractionManager = require('InteractionManager');

const invariant = require('invariant');

@@ -87,7 +88,11 @@ class Linking extends NativeEventEmitter {
* See https://facebook.github.io/react-native/docs/linking.html#getinitialurl
*/
getInitialURL(): Promise<?string> {
return LinkingManager.getInitialURL();
return Platform.OS === 'android'
? InteractionManager.runAfterInteractions().then(() =>
LinkingManager.getInitialURL(),
)
: LinkingManager.getInitialURL();
}

/*

0 comments on commit c802d0b

Please sign in to comment.
You can’t perform that action at this time.