Facing an issue with Sign in with Apple (SIWA) in tvOS

Hello,


I am facing the following issue while trying to Sign in with Apple (SIWA) on the tvOS simulator.


I have enabled the entitlements for SIWA in the project target. And the same steps are working fine in the iOS 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)
  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 {
    /// - Tag: provide_presentation_anchor
    @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)")
    }


Is apple sign in supported in the tvOS simulator? Or I am doing something wrong here?


Any leads are highly appreciated.

Answered by Frameworks Engineer in 612357022
Hi vijay_eros,

Sign In with Apple is not currently supported in the tvOS simulator. This is because the tvOS simulator is unable to become a trusted device and send a notification to an iOS trusted device.

We'd recommend using an Apple TV and setting it up using the same account as your test iOS device. You can pair the Apple TV with Xcode and debug your app wirelessly by following the steps outlined in Running Your App in the Simulator or on a Device

Thanks,
Patrick
Accepted Answer
Hi vijay_eros,

Sign In with Apple is not currently supported in the tvOS simulator. This is because the tvOS simulator is unable to become a trusted device and send a notification to an iOS trusted device.

We'd recommend using an Apple TV and setting it up using the same account as your test iOS device. You can pair the Apple TV with Xcode and debug your app wirelessly by following the steps outlined in Running Your App in the Simulator or on a Device

Thanks,
Patrick
Thanks for your reply Patrick.

I tried running that on Apple TV directly. I used the same apple id with which I am signed-in in my testing iPhone.

I am receiving push notification a bit delayed but on tap of push notification nothing happens, no callbacks, no errors.

Please help!
Facing an issue with Sign in with Apple (SIWA) in tvOS
 
 
Q