I have enabled the entitlements for SIWA in the project target. And the same steps are working fine in the iOS simulator.
I am facing the following issue while trying to Sign in with Apple (SIWA) on the tvOS simulator.
Steps to reproduce the issue:
- Upon requesting for SIWA on custom button tap, a full-screen layover displayed for the password of apple id (No option for choosing email relay was given) (screenshot attached in the last for reference)
- Upon entering the correct password I get the callback in the error delegate.
Error in the error delegate:
error Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1000 "(null)"
Below is the code-snippet attached for the whole process.
I have done all the steps required as per the official document of SIWA for iOS.
FYI: The same code is working for iOS for me but not for the tvOS. I have tested SIWA in the iPhone simulator while development and now trying the same with the tvOS but it isn't working.
Below is my code.
Here, function setup( ) is called on viewDidLoad of ViewController
private func setup() {
if #available(tvOS 13.0, *) {
let appleIDProvider = ASAuthorizationAppleIDProvider()
appleIDProvider.getCredentialState(forUserID: "myapp.identifiers.currentUserIdentifier") { (credential, error) in
switch credential {
case .authorized:
print("authorized for sign in")
break
case .notFound, .revoked, .transferred:
print("ready to logout")
break
default:
print("Apple sign in credential state unidentified")
}
}
}
}
Inside the action method of the custom SIWA button, my code looks like
if #available(tvOS 13.0, *) {
let appleIDProvider = ASAuthorizationAppleIDProvider()
let request = appleIDProvider.createRequest()
request.requestedScopes = [.fullName, .email]
let authorizationController = ASAuthorizationController(authorizationRequests: [request])
authorizationController.delegate = self
authorizationController.presentationContextProvider = self
authorizationController.performRequests()
}
The presentation anchor is set in the extension of ViewController
extension ENWelcomeScreenViewController: ASAuthorizationControllerPresentationContextProviding {
@available(tvOS 13.0, *)
func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
return self.view.window!
}
}
And finally, the error delegate, in which I am receiving the callback.
/// - Tag: did_complete_error
@available(tvOS 13.0, *)
func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
print("error \(error)")
}
Here is how it looks when the user taps on SIWA button.
Any leads are highly appreciated.
Just had the same issue. The simple solution is to take the term "nearby" more than literally. Hold your phone really close to the Apple TV when tapping the notification and everything will do its magic.