I’ve applied Register with Apple in a SwiftUI app utilizing AuthenticationServices
and SignInWithAppleButton
. The sign-in stream works as anticipated.
I perceive that there actually just isn’t a lot of a sign-out stream on the subject of Register with Apple. The sign-out is when the consumer revokes the authorization, and the app is anticipated to routinely verify the authorization standing and react accordingly.
Here’s a pattern of the sign-in stream itself:
SignInWithAppleButton(.signIn,
onRequest:
{
request in
request.requestedScopes = [.email, .fullName]
},
onCompletion:
{
end in
change outcome
{
case .success(let auth):
change auth.credential
{
case let credential as ASAuthorizationAppleIDCredential:
checkAuthorization(userId: credential.consumer)
default:
break
}
case .failure(let error):
print(error)
}
}
)
Here’s a pattern of checking the authorization standing, which is known as within the above stream and in addition periodically to verify the standing:
func checkAuthorization(userId: String)
{
let appleIDProvider = ASAuthorizationAppleIDProvider()
appleIDProvider.getCredentialState(forUserID: userId)
{
(credentialState, error) in
change credentialState
{
case .approved:
print("Register approved")
// Deal with approved standing.
case .revoked, .notFound:
print("Register revoked or not discovered")
// Deal with un-authorized standing.
default:
print("Register default case")
// Deal with default standing.
}
}
}
After efficiently signing in utilizing the SignInWithAppleButton
stream, I’ve examined revoking the authorization to see what occurs.
To revoke the authorization, both on the simulator itself or on my precise gadget, I’m going to Settings > Apple ID > Password & Safety > Register with Apple
and delete the authorization for my app.
Nonetheless, irrespective of how lengthy I wait, the app (working on a simulator) all the time returns a licensed standing for my userId
.
Am I lacking one thing? It has been about 12 hours since I manually revoked authorization and the userId
nonetheless returns a licensed standing.