I am using:-
The error message :
SwiftUI
Xcode 12 Beta
Code Block let pub = NotificationCenter.default .publisher(for: NSNotification.Name.ASAuthorizationAppleIDProviderCredentialRevoked)
The error message :
Type 'NSNotification.Name' has no member 'ASAuthorizationAppleIDProviderCredentialRevoked'
I just found it it's called
I test the app and it's working 👏😍
this all code I used:
Code Block ASAuthorizationAppleIDProvider.credentialRevokedNotification
without NSNotification.NameI test the app and it's working 👏😍
this all code I used:
Code Block import SwiftUI import AuthenticationServices @main struct AppName: App { @ObservedObject var userAuth: UserAuth = UserAuth() let pub = NotificationCenter.default .publisher(for: ASAuthorizationAppleIDProvider.credentialRevokedNotification) @SceneBuilder var body: some Scene { WindowGroup { ContentView() .environmentObject(userAuth) .onAppear(perform: { credentialState() }) .onReceive(pub, perform: { _ in credentialState() }) } } func credentialState() { let appleIDProvider = ASAuthorizationAppleIDProvider() appleIDProvider.getCredentialState(forUserID: UserDefaults.standard.string(forKey:"userProfileID") ?? "") { (credentialState, error) in switch credentialState { case .authorized: // The Apple ID credential is valid. userAuth.login() case .revoked, .notFound: // The Apple ID credential is either revoked or was not found. userAuth.logOut() default: break } } } }