diff --git a/wallets/rn_cli_wallet/package.json b/wallets/rn_cli_wallet/package.json index 29efe46f..0f06b7b1 100644 --- a/wallets/rn_cli_wallet/package.json +++ b/wallets/rn_cli_wallet/package.json @@ -21,6 +21,7 @@ "@craftzdog/react-native-buffer": "6.0.5", "@ethersproject/shims": "5.7.0", "@json-rpc-tools/utils": "1.7.6", + "@kangfenmao/react-native-minimizer": "1.0.4", "@react-native-async-storage/async-storage": "1.24.0", "@react-native-clipboard/clipboard": "1.14.1", "@react-native-community/netinfo": "11.3.2", diff --git a/wallets/rn_cli_wallet/src/utils/LinkingUtils.ts b/wallets/rn_cli_wallet/src/utils/LinkingUtils.ts index b010b365..7a69a74c 100644 --- a/wallets/rn_cli_wallet/src/utils/LinkingUtils.ts +++ b/wallets/rn_cli_wallet/src/utils/LinkingUtils.ts @@ -1,5 +1,6 @@ -import {Linking} from 'react-native'; +import {Linking, Platform} from 'react-native'; import Toast from 'react-native-toast-message'; +import Minimizer from '@kangfenmao/react-native-minimizer'; interface redirect { native?: string; @@ -12,13 +13,30 @@ interface Props { isLinkMode?: boolean; } +const goBackOrToast = () => { + if (Platform.OS === 'android') { + Toast.show({ + type: 'success', + text1: 'Success!', + text2: 'Redirecting to the dapp', + }); + Minimizer.goBack(); + } else { + Toast.show({ + type: 'success', + text1: 'Success!', + text2: 'Please go back to the dapp', + }); + } +}; + export const handleRedirect = ({peerRedirect, isLinkMode}: Props) => { try { if (isLinkMode) { Toast.show({ type: 'success', text1: 'Success!', - text2: 'Redirecting to the dapp...', + text2: 'Redirecting to the dapp', }); return; } @@ -29,28 +47,15 @@ export const handleRedirect = ({peerRedirect, isLinkMode}: Props) => { if (peerRedirect?.universal) { Linking.openURL(peerRedirect.universal); } else { - Toast.show({ - type: 'success', - text1: 'Success!', - text2: 'Please go back to the dapp', - }); + goBackOrToast(); } }); } else if (peerRedirect?.universal) { Linking.openURL(peerRedirect.universal); } else { - Toast.show({ - type: 'success', - text1: 'Success!', - text2: 'Please go back to the dapp', - }); + goBackOrToast(); } - } catch (error) { - console.log(error); - Toast.show({ - type: 'success', - text1: 'Success!', - text2: 'Please go back to the dapp', - }); + } catch (error: any) { + goBackOrToast(); } }; diff --git a/wallets/rn_cli_wallet/yarn.lock b/wallets/rn_cli_wallet/yarn.lock index b71b8f5f..091cc5b6 100644 --- a/wallets/rn_cli_wallet/yarn.lock +++ b/wallets/rn_cli_wallet/yarn.lock @@ -2640,6 +2640,16 @@ __metadata: languageName: node linkType: hard +"@kangfenmao/react-native-minimizer@npm:1.0.4": + version: 1.0.4 + resolution: "@kangfenmao/react-native-minimizer@npm:1.0.4" + peerDependencies: + react: "*" + react-native: "*" + checksum: b752ac3635acff719e3bd1bdcc7a47833b121c14d6133e0cc83fd5280b45a22b93b19795b9d6f7f07e6796a21af22dc7473fc14dbefd261da3765e54122b481b + languageName: node + linkType: hard + "@nicolo-ribaudo/eslint-scope-5-internals@npm:5.1.1-v1": version: 5.1.1-v1 resolution: "@nicolo-ribaudo/eslint-scope-5-internals@npm:5.1.1-v1" @@ -13179,6 +13189,7 @@ __metadata: "@craftzdog/react-native-buffer": 6.0.5 "@ethersproject/shims": 5.7.0 "@json-rpc-tools/utils": 1.7.6 + "@kangfenmao/react-native-minimizer": 1.0.4 "@react-native-async-storage/async-storage": 1.24.0 "@react-native-clipboard/clipboard": 1.14.1 "@react-native-community/netinfo": 11.3.2