Skip to content

Commit c802d0b

Browse files
Injung Chungfacebook-github-bot
Injung Chung
authored andcommitted
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
1 parent 16e4971 commit c802d0b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Libraries/Linking/Linking.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
const NativeEventEmitter = require('NativeEventEmitter');
1414
const NativeModules = require('NativeModules');
1515
const Platform = require('Platform');
16+
const InteractionManager = require('InteractionManager');
1617

1718
const invariant = require('invariant');
1819

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

9398
/*

0 commit comments

Comments
 (0)