diff --git a/app/components/Views/Entry/index.js b/app/components/Views/Entry/index.js index 172b4f774c0..7ea762497df 100644 --- a/app/components/Views/Entry/index.js +++ b/app/components/Views/Entry/index.js @@ -86,10 +86,9 @@ class Entry extends PureComponent { animation = React.createRef(); animationName = React.createRef(); opacity = new Animated.Value(1); + mounted = false; async componentDidMount() { - DeeplinkManager.init(this.props.navigation); - this.unsubscribeFromBranch = Branch.subscribe(this.handleDeeplinks); SplashScreen.hide(); const existingUser = await AsyncStorage.getItem('@MetaMask:existingUser'); if (existingUser !== null) { @@ -97,9 +96,23 @@ class Entry extends PureComponent { } else { this.animateAndGoTo('OnboardingRootNav'); } + DeeplinkManager.init(this.props.navigation); + this.unsubscribeFromBranch = Branch.subscribe(this.handleDeeplinks); + this.mounted = true; } - handleDeeplinks = ({ error, params, uri }) => { + waitUntilMounted = async () => { + if (this.mounted) return; + await new Promise(resolve => { + setTimeout(() => { + if (this.mounted) resolve(); + else this.waitUntilMounted(); + }, 2000); + }); + }; + + handleDeeplinks = async ({ error, params, uri }) => { + await this.waitUntilMounted(); if (error) { Logger.error(error, 'Error from Branch'); return; diff --git a/app/core/DeeplinkManager.js b/app/core/DeeplinkManager.js index 3c54c7c2433..141d3f0d773 100644 --- a/app/core/DeeplinkManager.js +++ b/app/core/DeeplinkManager.js @@ -60,7 +60,6 @@ class DeeplinkManager { params = qs.parse(urlObj.query.substring(1)); } const { MM_UNIVERSAL_LINK_HOST } = AppConstants; - switch (urlObj.protocol.replace(':', '')) { case 'http': case 'https': @@ -71,11 +70,7 @@ class DeeplinkManager { switch (action) { case 'wc': - params && - params.uri && - setTimeout(() => { - WalletConnect.newSession(params.uri, params.redirectUrl, false); - }, 1500); + params && params.uri && WalletConnect.newSession(params.uri, params.redirectUrl, false); break; case 'dapp': this.handleBrowserUrl(