无法在 watchOS 上使用 GameKit游戏中心对本地玩家进行身份验证 设置已经试过了

问题描述

我正在尝试将 Game Center 集成到 watchOS 应用中,但我无法对本地玩家进行身份验证。

也许我缺少任何步骤来允许配套的 watchOS 应用程序像 iOS 应用程序一样访问游戏中心?

设置

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

已经试过了

在我调用的 watchOS App Extension 上:

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.}

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

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

解决方法

经过数周的摸索,我发现(艰难的)Game Center 只能在真正的设备上运行在 watchOS 上,而且它的运行非常有限。

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

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

--

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

,

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...