From f61b4841438deeb674954ebd4d2e8af9c53d5427 Mon Sep 17 00:00:00 2001 From: Aben <5195693+rushairer@users.noreply.github.com> Date: Thu, 17 Nov 2022 17:24:21 +0800 Subject: [PATCH] Update OAuth2Authorizer+iOS.swift MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update OAuth2Authorizer+iOS.swift macCatalyst 13.1 need setting presentationContextProvider. If not will get an error: ``` Printing description of error: ▿ Optional - some : Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=2 "Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start." UserInfo={NSDebugDescription=Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start.} ``` --- Sources/iOS/OAuth2Authorizer+iOS.swift | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Sources/iOS/OAuth2Authorizer+iOS.swift b/Sources/iOS/OAuth2Authorizer+iOS.swift index b22d14f..8546453 100644 --- a/Sources/iOS/OAuth2Authorizer+iOS.swift +++ b/Sources/iOS/OAuth2Authorizer+iOS.swift @@ -167,12 +167,8 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI { self.webAuthenticationPresentationContextProvider = nil } - #if targetEnvironment(macCatalyst) authenticationSession = ASWebAuthenticationSession(url: url, callbackURLScheme: redirectURL.scheme, completionHandler: completionHandler) - return (authenticationSession as! ASWebAuthenticationSession).start() - #else - authenticationSession = ASWebAuthenticationSession(url: url, callbackURLScheme: redirectURL.scheme, completionHandler: completionHandler) - if #available(iOS 13.0, *) { + if #available(iOS 13.0, macCatalyst 13.1, *) { webAuthenticationPresentationContextProvider = OAuth2ASWebAuthenticationPresentationContextProvider(authorizer: self) if let session = authenticationSession as? ASWebAuthenticationSession { session.presentationContextProvider = webAuthenticationPresentationContextProvider as! OAuth2ASWebAuthenticationPresentationContextProvider @@ -180,7 +176,6 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI { } } return (authenticationSession as! ASWebAuthenticationSession).start() - #endif }