Skip to content

Instantly share code, notes, and snippets.

@henning-jh
Last active June 7, 2019 20:39
Show Gist options
  • Save henning-jh/9b0b4cd0a5484c5fc89afcab0c1c2426 to your computer and use it in GitHub Desktop.
Save henning-jh/9b0b4cd0a5484c5fc89afcab0c1c2426 to your computer and use it in GitHub Desktop.
Sign In with Apple: handle login result
extension MyLoginViewController: ASAuthorizationControllerDelegate {
func authorizationController(controller: ASAuthorizationController,
didCompleteWithAuthorization authorization: ASAuthorization) {
if let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential {
let userIdentifier = appleIDCredential.user
let fullName = appleIDCredential.fullName
let email = appleIDCredential.email
// Now we have the account information.
// We can store the userIdentifier in our account
// system as the username.
} else if let passwordCredential = authorization.credential as? ASPasswordCredential {
// Sign in using an existing iCloud Keychain credential.
let username = passwordCredential.user
let password = passwordCredential.password
// handle being logged in the old way
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment