React Native Redirect Example

React Native mobile apps will require a redirect to the web browser to create a users bank account. The following code example will provide an implementation where you can redirect to a web browser to add a bank account and then redirect the user back to your mobile app.

Example
1export default function HomeScreen() {
2 const [isLinking, setIsLinking] = useState(false);
3
4 const handleRedirect = () => {
5 const deepLinkUrl = 'exp://10.0.0.19:8081';
6
7 const session_key = "USER_SESSION_KEY" // replace with a session key generated here: https://docs.coinflow.cash/reference/getsessionkey
8 const coinflowUrl = `https://sandbox.coinflow.cash/solana/withdraw/YOUR_MERCHANT_ID?sessionKey=${session_key}&bankAccountLinkRedirect=${encodeURIComponent(deepLinkUrl)}`
9
10 console.log('coinflow url', coinflowUrl);
11
12 // open url in browswer
13 Linking.openURL(coinflowUrl).catch((error) => {
14 console.error('error opening url', error);
15 setIsLinking(false);
16 });
17 };
18
19 useEffect(() => {
20 handleRedirect();
21 }, []);
22
23 return null;
24}