From bdf45dd28b47f11a1fc85a31b5b0e768a318b3e7 Mon Sep 17 00:00:00 2001 From: Brian Ouellette Date: Wed, 24 Jun 2026 11:51:23 -0700 Subject: [PATCH] feat(ios): support HTTPS callback URLs via ASWebAuthenticationSessionCallback On iOS 17.4+, ASWebAuthenticationSession gained support for HTTPS Universal Link callbacks via ASWebAuthenticationSessionCallback. Previously, only custom URL schemes were supported for the redirect, which required registering a custom scheme and prevented use of standard HTTPS OAuth redirect URIs (e.g. for Universal Links / associated domains). This change detects when the redirectURL uses the https scheme and, on iOS 17.4+, creates an ASWebAuthenticationSessionCallback using callbackWithHTTPSHost:path: instead of passing a callbackURLScheme. Older iOS versions fall back to the existing custom scheme behavior. --- ios/RNInAppBrowser.m | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/ios/RNInAppBrowser.m b/ios/RNInAppBrowser.m index 2e835ed..a8edc79 100644 --- a/ios/RNInAppBrowser.m +++ b/ios/RNInAppBrowser.m @@ -99,21 +99,39 @@ + (BOOL)requiresMainQueueSetup } }; - NSString *escapedRedirectURL = nil; - if (redirectURL) { - escapedRedirectURL = [[NSURL alloc] initWithString:redirectURL].scheme; - } + NSURL *redirectNSURL = redirectURL ? [[NSURL alloc] initWithString:redirectURL] : nil; + BOOL isHTTPSRedirect = redirectNSURL && [redirectNSURL.scheme isEqualToString:@"https"]; + BOOL usedHTTPSCallback = NO; - if (@available(iOS 12.0, *)) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpartial-availability" +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_17_4) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_17_4 + if (isHTTPSRedirect && @available(iOS 17.4, *)) { + ASWebAuthenticationSessionCallback *httpsCallback = + [ASWebAuthenticationSessionCallback callbackWithHTTPSHost:redirectNSURL.host + path:redirectNSURL.path.length ? redirectNSURL.path : @"/"]; webAuthSession = [[ASWebAuthenticationSession alloc] initWithURL:url - callbackURLScheme:escapedRedirectURL - completionHandler:completionHandler]; - } else { - authSession = [[SFAuthenticationSession alloc] - initWithURL:url - callbackURLScheme:escapedRedirectURL + callback:httpsCallback completionHandler:completionHandler]; + usedHTTPSCallback = YES; + } +#endif +#pragma clang diagnostic pop + + if (!usedHTTPSCallback) { + NSString *callbackScheme = redirectNSURL.scheme; + if (@available(iOS 12.0, *)) { + webAuthSession = [[ASWebAuthenticationSession alloc] + initWithURL:url + callbackURLScheme:callbackScheme + completionHandler:completionHandler]; + } else { + authSession = [[SFAuthenticationSession alloc] + initWithURL:url + callbackURLScheme:callbackScheme + completionHandler:completionHandler]; + } } #pragma clang diagnostic push