Is Sign in with Apple (SIWA) supported in the tvOS simulator?

319 views Asked by At

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:

  1. 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)
  2. 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.

enter image description here

Any leads are highly appreciated.

2

There are 2 answers

0
edsa-steffen On

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.

0
Vijay Sanghavi On

The answer to my question is a big no!!

FINDINGS:

  1. We can not test the sign in with apple in the tvOS simulator.
  2. When I tried running the same on Apple TV it worked.
  3. After entering the apple id credentials to sign-in in my app I get the push notification on the device I am signed-in with the same apple id.
  4. Nothing happens when you tap on the received push notification.

On the Apple forum, I get a similar response from their engineering team.

enter image description here

Here is a screen capture of Apple TV.