mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
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 === null) {
|
|
return;
|
|
}
|
|
if (typeof event.url !== 'string') {
|
|
return;
|
|
}
|
|
if (event.url.indexOf('bitcoin:') === 0 || event.url.indexOf('BITCOIN:') === 0) {
|
|
this.navigator &&
|
|
this.navigator.dispatch(
|
|
NavigationActions.navigate({
|
|
routeName: 'SendDetails',
|
|
params: {
|
|
uri: event.url,
|
|
},
|
|
}),
|
|
);
|
|
} else if (event.url.indexOf('lightning:') === 0 || event.url.indexOf('LIGHTNING:') === 0) {
|
|
this.navigator &&
|
|
this.navigator.dispatch(
|
|
NavigationActions.navigate({
|
|
routeName: 'ScanLndInvoice',
|
|
params: {
|
|
uri: event.url,
|
|
},
|
|
}),
|
|
);
|
|
}
|
|
};
|
|
|
|
render() {
|
|
return (
|
|
<MainBottomTabs
|
|
ref={nav => {
|
|
this.navigator = nav;
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
}
|