Skip to content

Fixes issue with Cannot open WebView in the Assistive Access mode #894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#import <SafariServices/SafariServices.h>
#import <AuthenticationServices/AuthenticationServices.h>
#import <Accessibility/Accessibility.h>

#import "OIDErrorUtilities.h"
#import "OIDExternalUserAgentSession.h"
Expand Down Expand Up @@ -99,8 +100,12 @@ - (BOOL)presentExternalUserAgentRequest:(id<OIDExternalUserAgentRequest>)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 =
Expand Down