Skip to content

Instantly share code, notes, and snippets.

@Yoloabdo
Last active June 5, 2020 13:40
Show Gist options
  • Select an option

  • Save Yoloabdo/26733688274455cb2de28cf728b2d518 to your computer and use it in GitHub Desktop.

Select an option

Save Yoloabdo/26733688274455cb2de28cf728b2d518 to your computer and use it in GitHub Desktop.
@available(iOS 13.0, *)
class AppleAuthService: NSObject, AuthService {
private weak var viewController: UIViewController?
private weak var delegate: AuthServiceDelegate?
private var backendAuth: ServiceAuthorizer?
var authType: PreferredAuthMethod = .apple
init(_ viewController: UIViewController?, delegate: AuthServiceDelegate?) {
self.viewController = viewController
self.delegate = delegate
self.backendAuth = BackendAuthorizer(delegate: delegate)
}
func authenticate() {
let appleIDProvider = ASAuthorizationAppleIDProvider()
let request = appleIDProvider.createRequest()
request.requestedScopes = [.fullName, .email]
let authorizationController = ASAuthorizationController(authorizationRequests: [request])
authorizationController.delegate = self
authorizationController.presentationContextProvider = self
authorizationController.performRequests()
}
func deAuthenticate() {
// no sign out on apple method.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment