How to trigger prompt confirmation when DApps connecting to Wallet

32 views Asked by At

I just build my own wallet same as MetaMask, TrustWallet and etc. I want my wallet can connect to DApps using this flow:

  1. User will choose DApps browser (will open to webview)
  2. If the browser on webview already loaded then "Connect" button will clicked
  3. 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>
  );
0

There are 0 answers