From b856e4bdf4d3f5063c933bd103b70541751f8437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sharma?= <737941+loic-sharma@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:55:14 -0700 Subject: [PATCH] Fix OIDExternalUserAgentIOSCustomBrowser on iOS 10+ (#871) --- .../iOS/OIDExternalUserAgentIOSCustomBrowser.m | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m b/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m index be5dc820c..c49cbbf9c 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m @@ -145,7 +145,11 @@ - (BOOL)presentExternalUserAgentRequest:(nonnull id NSString *testURLString = [NSString stringWithFormat:@"%@://example.com", _canOpenURLScheme]; NSURL *testURL = [NSURL URLWithString:testURLString]; if (![[UIApplication sharedApplication] canOpenURL:testURL]) { - [[UIApplication sharedApplication] openURL:_appStoreURL]; + if (@available(iOS 10.0, *)) { + [[UIApplication sharedApplication] openURL:_appStoreURL options:@{} completionHandler:nil]; + } else { + [[UIApplication sharedApplication] openURL:_appStoreURL]; + } return NO; } } @@ -153,8 +157,14 @@ - (BOOL)presentExternalUserAgentRequest:(nonnull id // Transforms the request URL and opens it. NSURL *requestURL = [request externalUserAgentRequestURL]; requestURL = _URLTransformation(requestURL); - BOOL openedInBrowser = [[UIApplication sharedApplication] openURL:requestURL]; - return openedInBrowser; + if (@available(iOS 10.0, *)) { + BOOL willOpen = [[UIApplication sharedApplication] canOpenURL:requestURL]; + [[UIApplication sharedApplication] openURL:requestURL options:@{} completionHandler:nil]; + return willOpen; + } else { + BOOL openedInBrowser = [[UIApplication sharedApplication] openURL:requestURL]; + return openedInBrowser; + } } - (void)dismissExternalUserAgentAnimated:(BOOL)animated