gpt4 book ai didi

ios - tvOS 模拟器是否支持 Sign in with Apple (SIWA)?

转载 作者:行者123 更新时间:2023-12-01 16:11:53 25 4
gpt4 key购买 nike

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

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

重现问题的步骤:

  • 在自定义按钮点击请求 SIWA 时,Apple id 的密码显示全屏停留(未给出选择电子邮件中继的选项)(最后附上截图以供引用)
  • 输入正确的密码后,我会在错误委托(delegate)中获得回调。

  • 错误委托(delegate)中的错误:

    error Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1000 "(null)"



    以下是整个过程的代码片段。

    我已经按照 SIWA for iOS 的官方文档完成了所有需要的步骤。

    仅供引用:相同的代码适用于我的 iOS,但不适用于 tvOS。我在开发时在 iPhone 模拟器中测试了 SIWA,现在尝试在 tvOS 上进行相同的测试,但它不起作用。

    下面是我的代码。

    这里,在 ViewController 的 viewDidLoad 上调用了 setup() 函数
    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 按钮的操作方法中,我的代码看起来像
       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()
    }

    演示 anchor 设置在 ViewController 的扩展中
    extension ENWelcomeScreenViewController: ASAuthorizationControllerPresentationContextProviding {
    @available(tvOS 13.0, *)
    func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
    return self.view.window!
    }
    }

    最后是错误委托(delegate),我在其中接收回调。
     /// - Tag: did_complete_error  
    @available(tvOS 13.0, *)
    func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
    print("error \(error)")
    }

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

    enter image description here

    任何线索都受到高度赞赏。

    最佳答案

    我的问题的答案是一个很大的不!
    发现:

  • 我们无法在 tvOS 模拟器中测试使用 Apple 登录。
  • 当我尝试在 Apple TV 上运行它时,它起作用了。
  • 输入苹果 ID 凭据以登录我的应用程序后,我在使用相同苹果 ID 登录的设备上收到推送通知。
  • 当您点击收到的推送通知时,没有任何 react 。

  • Apple forum ,我从他们的工程团队那里得到了类似的回应。
    enter image description here
    这是 Apple TV 的屏幕截图。

    关于ios - tvOS 模拟器是否支持 Sign in with Apple (SIWA)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62370226/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com