I just build my own wallet same as MetaMask, TrustWallet and etc. I want my wallet can connect to DApps using this flow:
- User will choose DApps browser (will open to webview)
- If the browser on webview already loaded then "Connect" button will clicked
- And will going back to native app to display the prompt for confirmation connect to the DApps already choosed
The problem is when i click connect not triggered anything to my app, i use this below code to triggered. If you have any other way please tell me. Thanks
const onMessage = (event: any) => {
const data = JSON.parse(event.nativeEvent.data);
console.log('triggered on here', data);
if (data.type === 'web3') {
console.log('Data from WebView:', data.data);
}
};
return (
<View style={styles.container}>
<NavBar navigation={navigation} title={getData().title} containerStyle={styles.background} />
<WebView source={{ uri: 'https://pancakeswap.finance/' }} onMessage={onMessage} />
</View>
);