Wednesday, December 6, 2023

Does testnet bitcoin pockets help redirections?


We are attempting to combine bitcoin testnet pockets with react native dapp usin deep linking. Such that when person tries to ship btc he might be directed to bitcoin testnet pockets and as soon as transaction is submitted person might be redirected again to react native dapp.

tried following code pattern :

deeplink used:

bitcoin:${bitcoinAddress}?quantity=${quantity}&label=${label}&message=${message}&r=${encodeURIComponent(
      redirectUrl
    )}&callback=${encodeURIComponent(callbackUrl)}

pockets app used:

https://play.google.com/retailer/apps/particulars?id=de.schildbach.wallet_test&hl=en&gl=US

import React, { AppState,useEffect } from "react";
import { Linking, View, Button } from "react-native";

const App = () => {
  const onPressHandler = () => {
    const bitcoinAddress = "2NCXR2f6QsrUf4Kfpz99bctNA96vUw9j4bP";
    const quantity = "0.000001";
    const label = "Take a look at transaction";
    const message = "This can be a check transaction";
    const callbackUrl = "myapp://transaction_callback";
    const redirectUrl = "myapp://redirect_back";

    // Create the deep hyperlink URL with the callback and redirect URLs
    const deepLinkUrl = `bitcoin:${bitcoinAddress}?quantity=${quantity}&label=${label}&message=${message}&r=${encodeURIComponent(
      redirectUrl
    )}&callback=${encodeURIComponent(callbackUrl)}`;

    // Open the deep hyperlink URL within the person's Bitcoin pockets app
    Linking.openURL(deepLinkUrl);
  };

  operate handleUrl(url) {
    // Deal with the deep hyperlink URL right here
    console.log('Obtained deep hyperlink:', url);
  }
  
  operate handleAppStateChange(appState) {
    if (appState === 'energetic') {
      Linking.getInitialURL().then(url => {
        console.log("check herrr")
        handleUrl(url)
      });
    }
  }

  useEffect(() => {
    AppState.addEventListener('change', handleAppStateChange);
    return () => AppState.removeEventListener('change', handleAppStateChange);

  }, []);

  return (
    // your app code right here
    <View>
      <Textual content>check</Textual content>
      <Button title="Press me" onPress={onPressHandler} colour="#841584" />
    </View>
  );
};

export default App;

Are there every other wallets which help redirections again to dapp and which help testnet?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles