Skip to content

Commit b856e4b

Browse files
authored
Fix OIDExternalUserAgentIOSCustomBrowser on iOS 10+ (#871)
1 parent d4cbdfa commit b856e4b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,26 @@ - (BOOL)presentExternalUserAgentRequest:(nonnull id<OIDExternalUserAgentRequest>
145145
NSString *testURLString = [NSString stringWithFormat:@"%@://example.com", _canOpenURLScheme];
146146
NSURL *testURL = [NSURL URLWithString:testURLString];
147147
if (![[UIApplication sharedApplication] canOpenURL:testURL]) {
148-
[[UIApplication sharedApplication] openURL:_appStoreURL];
148+
if (@available(iOS 10.0, *)) {
149+
[[UIApplication sharedApplication] openURL:_appStoreURL options:@{} completionHandler:nil];
150+
} else {
151+
[[UIApplication sharedApplication] openURL:_appStoreURL];
152+
}
149153
return NO;
150154
}
151155
}
152156

153157
// Transforms the request URL and opens it.
154158
NSURL *requestURL = [request externalUserAgentRequestURL];
155159
requestURL = _URLTransformation(requestURL);
156-
BOOL openedInBrowser = [[UIApplication sharedApplication] openURL:requestURL];
157-
return openedInBrowser;
160+
if (@available(iOS 10.0, *)) {
161+
BOOL willOpen = [[UIApplication sharedApplication] canOpenURL:requestURL];
162+
[[UIApplication sharedApplication] openURL:requestURL options:@{} completionHandler:nil];
163+
return willOpen;
164+
} else {
165+
BOOL openedInBrowser = [[UIApplication sharedApplication] openURL:requestURL];
166+
return openedInBrowser;
167+
}
158168
}
159169

160170
- (void)dismissExternalUserAgentAnimated:(BOOL)animated

0 commit comments

Comments
 (0)