diff --git a/src/esr.ts b/src/esr.ts index 575bcac..17ce128 100644 --- a/src/esr.ts +++ b/src/esr.ts @@ -95,7 +95,9 @@ export async function createIdentityRequest( if (typeof window !== 'undefined') { const returnUrl = generateReturnUrl() sameDeviceRequest.setInfoKey('same_device', true) - sameDeviceRequest.setInfoKey('return_path', returnUrl) + if (returnUrl !== undefined) { + sameDeviceRequest.setInfoKey('return_path', returnUrl) + } } // Return the request and the callback data diff --git a/src/utils.ts b/src/utils.ts index cb7103f..d418a2f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -59,7 +59,12 @@ export function uuid(): string { } /** Generate a return url that Anchor will redirect back to w/o reload. */ -export function generateReturnUrl() { +export function generateReturnUrl(): string | undefined { + // Return undefined for iOS React Native apps to prevent redirect to Safari + if (isAppleHandheld() && isReactNativeApp()) { + return undefined + } + if (isChromeiOS()) { // google chrome on iOS will always open new tab so we just ask it to open again as a workaround return 'googlechrome://'