Skip to content

Commit

Permalink
Make Linking.getInitialURL works properly even if current activity is…
Browse files Browse the repository at this point in the history
… 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
Injung Chung authored and facebook-github-bot committed May 8, 2019
1 parent 16e4971 commit c802d0b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Libraries/Linking/Linking.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
const NativeEventEmitter = require('NativeEventEmitter');
const NativeModules = require('NativeModules');
const Platform = require('Platform');
const InteractionManager = require('InteractionManager');

const invariant = require('invariant');

Expand Down Expand Up @@ -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();
}

/*
Expand Down

0 comments on commit c802d0b

Please sign in to comment.