My app has a "Sign in with the Apple" account feature. I am wondering if there is sign out feature from the Apple account.
I tried the below but doesn't get success
let request = ASAuthorizationAppleIDProvider().createRequest()
request.requestedOperation = .operationLogout
let authorizationController = ASAuthorizationController(authorizationRequests: [request])
authorizationController.performRequests()
Open Keychain Access, go to the Passwords category and remove the passwords associated with Xcode. Their name contains apple.com (example: daw2.apple.com).
You can log in and set up multiple Apple IDs on an iOS device from the Settings app, and use them for different purposes like contacts, email, notes, bookmarks, etc.
Apple only allows currently for the user to perform a signout (iOS/watchOS/tvOS) or shown as a revoke of permissions to us. They recommend you get the state of the credentials before use to check for revoke and if that has occurred to delete any local information (Remove the user identifier where ever you have it stored) (And possibly change UI if needed; For example like showing login view).
let appleIDProvider = ASAuthorizationAppleIDProvider()
appleIDProvider.getCredentialState(forUserID: KeychainItem.currentUserIdentifier) { (credentialState, error) in
switch credentialState {
case .authorized:
// The Apple ID credential is valid.
break
case .revoked:
// The Apple ID credential is revoked.
break
case .notFound:
// No credential was found, so show the sign-in UI.
break
default:
break
}
}
You could provide a prompt to the user on signout guiding them to revoke in their device's settings as well and listen for the change notification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With