【发布时间】: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