From ff381056a1d0cbb36572a76b7e84f69c3ce33f96 Mon Sep 17 00:00:00 2001 From: Alexandros Kalogerakis Date: Mon, 9 Dec 2024 14:49:11 +0200 Subject: [PATCH] fix: auto-sign not redirecting back to browser --- src/composables/deepLinkApi.ts | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/composables/deepLinkApi.ts b/src/composables/deepLinkApi.ts index a426f9d5c..900a3c909 100644 --- a/src/composables/deepLinkApi.ts +++ b/src/composables/deepLinkApi.ts @@ -4,7 +4,12 @@ import { useIonRouter } from '@ionic/vue'; import { ROUTE_ACCOUNT } from '@/popup/router/routeNames'; import { checkIfSuperheroCallbackUrl } from '@/utils'; -import { IS_IOS, IS_MOBILE_APP, MODAL_TRANSFER_SEND } from '@/constants'; +import { + IS_IOS, + IS_MOBILE_APP, + IS_WEB, + MODAL_TRANSFER_SEND, +} from '@/constants'; import { useModals } from '@/composables/modals'; export function useDeepLinkApi() { @@ -45,11 +50,19 @@ export function useDeepLinkApi() { decodeURIComponent(String(route.query[isSuccess ? 'x-success' : 'x-cancel'])), ) as string; router.replace({ name: ROUTE_ACCOUNT }); - if (IS_MOBILE_APP && !IS_IOS) { - window.open(callbackUrl, '_system'); - } else { - window.open(callbackUrl, '_self'); - } + /** + * When auto-sign is enabled (daily spend limit), + * there are cases (mostly on iOS) where it's not redirecting back to the callback URL. + * This might be due to the time it takes for iOS to animate the navigation. + * Adding a small delay fixes this + */ + setTimeout(() => { + if (IS_MOBILE_APP && !IS_IOS) { + window.open(callbackUrl, '_system'); + } else { + window.open(callbackUrl, '_self'); + } + }, IS_WEB ? 0 : 300); } return {