tvOS模拟器是否支持使用Apple登录(SIWA)? [英] Is Sign in with Apple (SIWA) supported in the tvOS simulator?

查看:281
本文介绍了tvOS模拟器是否支持使用Apple登录(SIWA)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在项目目标中启用了SIWA的权利.同样的步骤在iOS模拟器中也可以正常工作.

I have enabled the entitlements for SIWA in the project target. And the same steps are working fine in the iOS simulator.

尝试在tvOS模拟器上使用Apple(SIWA)登录时遇到以下问题.

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

重现此问题的步骤:

  1. 在自定义按钮上请求SIWA时,将显示全屏的Apple ID密码停留(未提供选择电子邮件中继的选项)(最后一个屏幕截图供参考)
  2. 输入正确的密码后,我会在错误委托中得到回调.

错误委托中的错误:

错误错误Domain = com.apple.AuthenticationServices.AuthorizationError代码= 1000(空)"

下面是整个过程的代码段.

Below is the code-snippet attached for the whole process.

我已按照SIWA for iOS的正式文档完成了所有必需的步骤.

I have done all the steps required as per the official document of SIWA for iOS.

仅供参考:相同的代码对我来说适用于iOS,但不适用于tvOS.在开发过程中,我已经在iPhone模拟器中测试了SIWA,现在在tvOS上尝试了同样的操作,但是它不起作用.

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.

下面是我的代码.

在这里,在ViewController的viewDidLoad上调用函数setup()

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")  
            }  

        }  
    }  
}  

在自定义SIWA按钮的操作方法中,我的代码如下

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()  
    } 

演示锚点是在ViewController的扩展名中设置的

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)")  
    }  

这是用户点击SIWA按钮时的外观.

Here is how it looks when the user taps on SIWA button.

任何潜在客户都受到高度赞赏.

Any leads are highly appreciated.

推荐答案

我的问题的答案很不正确!

The answer to my question is a big no!!

发现:

  1. 我们无法在tvOS模拟器中使用Apple测试登录.
  2. 当我尝试在Apple TV上运行它时,它起作用了.
  3. 输入Apple ID凭据以在我的应用程序中登录后,我会在使用相同Apple ID登录的设备上收到推送通知.
  4. 当您点击收到的推送通知时,什么也没有发生.

Apple论坛上,我收到了他们的工程团队的类似回复.

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

这是Apple TV的屏幕截图.

Here is a screen capture of Apple TV.

这篇关于tvOS模拟器是否支持使用Apple登录(SIWA)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆