【问题标题】:Unable to authenticate Local Player with GameKit (Game Center) on watchOS无法在 watchOS 上使用 GameKit(游戏中心)对本地玩家进行身份验证
【发布时间】:2023-04-05 07:26:01
【问题描述】:

我正在尝试将 Game Center 集成到 watchOS 应用,但我无法验证本地播放器。

也许我错过了允许配套 watchOS 应用像 iOS 应用一样访问 Game Center 的任何步骤?

设置

  • iOS 14 的 iOS 应用部署目标
  • Companion watchOS App 支持在不安装 iOS App 的情况下运行,目标 watchOS 7
  • Game Center 功能在 iOS 和 watchOS 应用扩展目标上均处于活动状态
  • 该应用尚未上线,但已在 App Store Connect 上的“准备提交”中
  • Game Center 复选框已打开,在 App Store Connect 上
  • App Store Connect 上已经创建了一些排行榜
  • iOS 应用能够连接到 Game Center 以进行身份​​验证、提交分数和显示排行榜
  • 在模拟器上进行测试时,我将 iPhone 与 Watch 配对。沙盒帐户已在 iPhone 上进行身份验证。
  • 在真实设备上测试时,我将 iPhone 与 Watch 配对,真实帐户在 iPhone 上进行身份验证。

已经尝试过

在我调用的 watchOS 应用扩展上:

GKLocalPlayer.local.authenticateHandler = { error in

}

这与用于在 iOS 上进行身份验证的方法非常相似,并且在 iOS 上它可以工作,甚至在模拟器上也是如此。


当调用该方法并在模拟器上运行时,我会在 Xcode 的调试区域获得以下日志:

[Error] _authenticateUsingAlert:Failed to authenticate player with existing credentials.Error: Error Domain=GKErrorDomain Code=6 "The requested operation could not be completed because local player has not been authenticated." UserInfo={NSLocalizedDescription=The requested operation could not be completed because local player has not been authenticated.}

并且在完成处理程序上收到的错误消息是:

Error Domain=GKErrorDomain Code=3 "The requested operation could not be completed due to an error communicating with the server." UserInfo={NSLocalizedDescription=The requested operation could not be completed due to an error communicating with the server.}

在真实设备上测试相同的场景时,我得到了日志:

[Error] _authenticateUsingAlert:Failed to authenticate player with existing credentials.Error: Error Domain=GKErrorDomain Code=15 "The requested operation could not be completed because this application is not recognised by Game Center." UserInfo={GKServerStatusCode=5019, NSUnderlyingError=0x11e3a6c0 {Error Domain=GKServerErrorDomain Code=5019 "status = 5019, no game matching descriptor: ios:com.myApp.test.watch.extension::0+-1" UserInfo={GKServerStatusCode=5019, NSLocalizedFailureReason=status = 5019, no game matching descriptor: ios:com.myApp.test.watch.extension::0+-1}}, NSLocalizedDescription=The requested operation could not be completed because this application is not recognised by Game Center.}

完成处理程序的错误是:

Error Domain=GKErrorDomain Code=15 "The requested operation could not be completed because this application is not recognised by Game Center." UserInfo={NSLocalizedDescription=The requested operation could not be completed because this application is not recognised by Game Center.}

这两个错误都类似于您在 iOS 上收到的消息,当应用未在 App Store Connect 上启用 Game Center 时。如前所述,情况并非如此,因为在 iOS 上可以正常工作。

我还尝试将应用移至 App Store Connect 上的 Game Center Group,因为它说这是为了分享排行榜和成就,但结果是一样的。

【问题讨论】:

    标签: swift apple-watch game-center gamekit watchos


    【解决方案1】:

    经过数周的努力,我发现(艰难地)Game Center在真正的设备上才能在 watchOS 上工作,而且工作非常有限。

    您可以访问本地玩家显示名称,但不能提交分数。

    我什至尝试将应用添加到 Game Center Groups,但没有帮助。

    --

    附言。它仍然会在 Xcode 的控制台上显示错误消息和警告,指出用户未通过身份验证或 Game Center 无法识别该应用程序,但如果您在使用GKLocalPlayer.local.authenticateHandler 进行身份验证后尝试获取GKLocalPlayer.local.displayName,它将起作用。它显然也会向排行榜提交分数,或者至少不会显示错误,但分数永远不会被提交。

    【讨论】:

      【解决方案2】:

      我遇到了类似的错误,但它与使用 Apple Watch OS 无关,但是我遇到了这个错误,这是一个简单的疏忽,因为我在 App Store connect 上添加应用程序时没有放置正确的捆绑标识符,所以如果你有类似的尝试检查捆绑标识符是否与您的项目相对应。

      【讨论】:

      • 不幸的是,它与捆绑标识符无关。该应用已经上线,iOS 应用可以按预期与 GameKit 进行交互。
      猜你喜欢
      • 2014-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-29
      • 2016-05-11
      • 2015-01-21
      • 1970-01-01
      • 2019-10-30
      相关资源
      最近更新 更多