diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h index 4ab6c7452..58a4f48cd 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h @@ -41,7 +41,7 @@ API_UNAVAILABLE(macCatalyst) /*! @brief The designated initializer. @param presentingViewController The view controller from which to present the authentication UI. @discussion The specific authentication UI used depends on the iOS version and accessibility - options. iOS 12+ uses @c ASWebAuthenticationSession (unless Guided Access is on), + options. iOS 12+ uses @c ASWebAuthenticationSession (unless Guided Access or Assistive Access is on), otherwise local browser is used. */ - (nullable instancetype)initWithPresentingViewController: @@ -52,7 +52,7 @@ API_UNAVAILABLE(macCatalyst) @param presentingViewController The view controller from which to present the browser. @param prefersEphemeralSession Whether the caller prefers to use a private authentication session. See @c ASWebAuthenticationSession.prefersEphemeralWebBrowserSession for more. - @discussion Authentication is performed with @c ASWebAuthenticationSession (unless Guided Access + @discussion Authentication is performed with @c ASWebAuthenticationSession (unless Guided Access or Assistive Access is on), setting the ephemerality based on the argument. */ - (nullable instancetype)initWithPresentingViewController: diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m index 7a3fa2278..321ee9a3b 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m @@ -24,6 +24,7 @@ #import #import +#import #import "OIDErrorUtilities.h" #import "OIDExternalUserAgentSession.h" @@ -99,8 +100,12 @@ - (BOOL)presentExternalUserAgentRequest:(id)request // iOS 12 and later, use ASWebAuthenticationSession if (@available(iOS 12.0, *)) { - // ASWebAuthenticationSession doesn't work with guided access (rdar://40809553) - if (!UIAccessibilityIsGuidedAccessEnabled()) { + BOOL assistiveAccessEnabled = NO; + if (@available(iOS 18.0, *)) { + assistiveAccessEnabled = AXAssistiveAccessEnabled(); + } + // ASWebAuthenticationSession doesn't work with guided access (rdar://40809553) or assistive access + if (!UIAccessibilityIsGuidedAccessEnabled() && !assistiveAccessEnabled) { __weak OIDExternalUserAgentIOS *weakSelf = self; NSString *redirectScheme = request.redirectScheme; ASWebAuthenticationSession *authenticationVC =