7

我正在尝试使用 Game Center 对 GKLocalPlayer 进行身份验证。但是,Apple 提供的代码

- (void) authenticateLocalPlayer
{
    [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
         if (error == nil)
         {
              // Insert code here to handle a successful authentication.
              NSLog(@"Logged in.");
         }
         else
         {
             // Your application can process the error parameter to report the error to the player.
             NSLog(@"%@", [error description]);
         }
     }];
}

似乎对我没有用。我总是收到“无法连接到 Game Center 服务器”的警报。可以选择“重试”或“取消”。两个 NSLog 语句都没有执行,所以我猜 completionHandler 甚至没有被触发。

如果我按重试,我会收到以下错误:

Error Domain=GKErrorDomain Code=7 "The requested operation could not be completed because local player is already authenticating." UserInfo=0x8915f80 {NSLocalizedDescription=The requested operation could not be completed because local player is already authenticating.}

有人知道出了什么问题吗?

4

3 回答 3

7

我在连接到 Game Center 时发现的一个可能问题是设备上的日期可能有误。检查您的日期是否是实际的当前日期。不知何故,游戏中心不允许来自日期不正确的设备的连接。

于 2011-01-11T19:40:25.450 回答
1

您可以尝试将模拟器完全重置为默认值。它对我有用,一旦它被重置,我的 iDevice 就会再次工作。

取决于你无法登录的ios版本,然后将模拟器设置为前台并转到左上角。iOS 模拟器 -> 重置内容和设置 -> 点击重置按钮。

我希望这有帮助。

于 2013-04-11T17:40:03.663 回答
0

这里完全相同的问题。昨天早上它对我来说大约有五分之一的工作。今天我什至一次都无法登录游戏中心沙盒(使用您发布的相同代码)。

编辑:我将部署目标更改为 3.0“项目 - 编辑活动目标 - iOS 部署目标”

然后我能够为我的活动可执行文件选择 4.1 模拟器,我可以登录并且一切正常。我猜4.2沙盒的东西......

于 2010-09-20T00:16:35.827 回答