mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
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](1e8f3b1102/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: https://github.com/facebook/react-native/pull/24748
Differential Revision: D15258046
Pulled By: cpojer
fbshipit-source-id: 0ec1c873766ae90955d47e5e023556eb6c5d5fbb
This commit is contained in:
committed by
Facebook Github Bot
parent
16e4971121
commit
c802d0b757
@@ -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();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user