BlueWallet/App.js

61 lines
1.4 KiB
JavaScript
Raw Normal View History

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 => {
2018-12-22 15:25:34 +01:00
if (event.url === null) {
2018-12-22 04:23:52 +01:00
return;
}
2018-12-22 15:25:34 +01:00
if (typeof event.url !== 'string') {
2018-12-22 04:23:52 +01:00
return;
}
if (event.url.indexOf('bitcoin:') === 0 || event.url.indexOf('BITCOIN:') === 0) {
2018-12-29 19:24:51 +01:00
this.navigator &&
this.navigator.dispatch(
NavigationActions.navigate({
routeName: 'SendDetails',
params: {
uri: event.url,
},
}),
);
2018-12-24 16:29:33 +01:00
} else if (event.url.indexOf('lightning:') === 0 || event.url.indexOf('LIGHTNING:') === 0) {
2018-12-29 19:24:51 +01:00
this.navigator &&
this.navigator.dispatch(
NavigationActions.navigate({
routeName: 'ScanLndInvoice',
params: {
uri: event.url,
},
}),
);
}
};
render() {
return (
<MainBottomTabs
ref={nav => {
this.navigator = nav;
}}
/>
);
}
}