diff --git a/App.js b/App.js new file mode 100644 index 000000000..b94ef1bc0 --- /dev/null +++ b/App.js @@ -0,0 +1,45 @@ +import React from 'react'; +import { Linking } from 'react-native'; +import { NavigationActions } from 'react-navigation'; + +import MainBottomTabs from './MainBottomTabs'; + +export default class App extends React.Component { + navigator = null; + + componentDidMount() { + Linking.getInitialURL() + .then(url => this.handleOpenURL({ url })) + .catch(console.error); + + Linking.addEventListener('url', this.handleOpenURL); + } + + componentWillUnmount() { + Linking.removeEventListener('url', this.handleOpenURL); + } + + handleOpenURL = event => { + if (event.url && event.url.indexOf('bitcoin:') === 0) { + this.navigator && + this.navigator.dispatch( + NavigationActions.navigate({ + routeName: 'SendDetails', + params: { + uri: event.url, + }, + }), + ); + } + }; + + render() { + return ( + { + this.navigator = nav; + }} + /> + ); + } +} diff --git a/index.js b/index.js index f37414a25..fbefbcb45 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ import React from 'react'; import './shim.js'; -import MainBottomTabs from './MainBottomTabs'; +import App from './App'; import { Sentry } from 'react-native-sentry'; import { AppRegistry } from 'react-native'; import WalletMigrate from './screen/wallets/walletMigrate'; @@ -28,7 +28,7 @@ class BlueAppComponent extends React.Component { } render() { - return this.state.isMigratingData ? this.setIsMigratingData()} /> : ; + return this.state.isMigratingData ? this.setIsMigratingData()} /> : ; } }