Merge pull request #480 from t4t5/master

Support Safello redirect URLs
This commit is contained in:
Overtorment 2019-05-10 20:56:46 +01:00 committed by GitHub
commit 4ef3340b52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 1 deletions

21
App.js
View File

@ -95,6 +95,12 @@ export default class App extends React.Component {
return isValidLightningInvoice;
}
isSafelloRedirect(event) {
let urlObject = url.parse(event.url, true) // eslint-disable-line
return !!urlObject.query["safello-state-token"]
}
handleOpenURL = event => {
if (event.url === null) {
return;
@ -122,6 +128,21 @@ export default class App extends React.Component {
},
}),
);
} else if (this.isSafelloRedirect(event)) {
let urlObject = url.parse(event.url, true) // eslint-disable-line
const safelloStateToken = urlObject.query["safello-state-token"]
this.navigator &&
this.navigator.dispatch(
NavigationActions.navigate({
routeName: "BuyBitcoin",
params: {
uri: event.url,
safelloStateToken,
},
}),
)
} else {
let urlObject = url.parse(event.url, true); // eslint-disable-line
console.log('parsed', urlObject);

View File

@ -63,7 +63,21 @@ export default class BuyBitcoin extends Component {
return <BlueLoading />;
}
return <WebView source={{ uri: 'https://bluewallet.io/buy-bitcoin-redirect.html?address=' + this.state.address }} />;
const { safelloStateToken } = this.props.navigation.state.params
let uri = "https://bluewallet.io/buy-bitcoin-redirect.html?address=" + this.state.address
if (safelloStateToken) {
uri += "&safelloStateToken=" + safelloStateToken
}
return (
<WebView
source={{
uri,
}}
/>
)
}
}
@ -74,6 +88,7 @@ BuyBitcoin.propTypes = {
params: PropTypes.shape({
address: PropTypes.string,
secret: PropTypes.string,
safelloStateToken: PropTypes.string,
}),
}),
}),