Last active
June 5, 2020 14:07
-
-
Save Yoloabdo/6e8fa79ba227dc9c055ab85418d9f735 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @available(iOS 13.0, *) | |
| extension AppleAuthService: ASAuthorizationControllerDelegate { | |
| func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { | |
| if let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential { | |
| backendAuth?.authorize(appleIDCredential) | |
| } | |
| } | |
| func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) { | |
| switch error { | |
| case let error as ASAuthorizationError: | |
| delegate?.authService(authType, didFailToAuthorizeWith: AuthenticationError.appleError(code: error.errorCode)) | |
| default: | |
| delegate?.authService(authType, didFailToAuthorizeWith: error) | |
| } | |
| } | |
| } | |
| @available(iOS 13.0, *) | |
| extension AppleAuthService: ASAuthorizationControllerPresentationContextProviding { | |
| func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { | |
| guard let window = viewController?.view.window else { | |
| fatalError("couldn't find window") | |
| } | |
| return window | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment