I created Apple sign in like here - https://developer.apple.com/documentation/authenticationservices/implementing_user_authentication_with_sign_in_with_apple
I Apples example all work fine.
In my project I added "Sign in with Apple" in the "Signing and Capabilities". I checked "Sign in with Apple" in the developer portal (Certificates, Identifiers & Profiles).
I get user credentials. It is part work fine.
		switch authorization.credential {
		case let appleIDCredential as ASAuthorizationAppleIDCredential:
				
				let user = User(credentials: appleIDCredential)
				self.saveUserInKeychain(user.id)
				
				let txt = "\(user.id)\n\(user.first_name) \(user.last_name)\n\(user.email)"
				let alert = UIAlertController(title: "OK", message: txt, preferredStyle: UIAlertController.Style.alert)
				alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: { alertAction in
						alert.dismiss(animated: true, completion: nil)
				}))
				self.present(alert, animated: true, completion: nil)
		default:
				break
		}
}
User state here is 1.
But in the AppDelegate, when I build again I had status .notFound and error:
Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1000 "(null)" For AppDelegate I use the same code from Apples example:
				let appleIDProvider = ASAuthorizationAppleIDProvider()
				appleIDProvider.getCredentialState(forUserID: KeychainItem.currentUserIdentifier) { (credentialState, error) in
						print(error)
						switch credentialState {
						case .authorized:
								DispatchQueue.main.async {
										self.window?.rootViewController?.showMainViewControllerAuth()
								}
						case .revoked, .notFound:
								DispatchQueue.main.async {
										self.window?.rootViewController?.showMainViewControllerNoAuth()
								}
						default:
								break
						}
				}
User state here is 2!
I was submitting a build to TestFlight and also had error .notFound (user state is 2). Apples example work fine in iOS simulator. But not my.
I think problem is here
Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1000 "(null)" Xcode 11.3. Swift 4.2. Target iOS 11.0 What could I forget?
Selecting any option will automatically load the page