4

我正在尝试调用游戏中心的身份验证方法,但是没有出现身份验证屏幕并且回调返回错误:“请求的操作已被取消”。

编码 :

[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error)
     {
        NSDictionary *userInfo = nil;
        if (error == nil) {

            NSLog(@"Game Center successfully authenticated");
        }
        else {
            userInfo = [NSDictionary dictionaryWithObject:error forKey:@"NSError"];
        }
        [[NSNotificationCenter defaultCenter] postNotificationName:Notification
                                                            object:self
                                                          userInfo:userInfo];

    }];

知道什么会导致这个问题吗?

4

2 回答 2

17

在 iOS 4.2 中,当用户取消登录 Game Center 时,尝试 3 次后返回该错误。您可以通过使用 Game Center 应用程序登录来解决错误,然后再次尝试您的应用程序,您应该会在应用程序中看到来自 Game Center 的欢迎返回消息

于 2010-12-12T04:57:00.987 回答
-1

在测试特定设备上是否可以使用游戏中心后,您应该执行类似的操作:

GKLocalPlayer *localplayer = [GKLocalPlayer localPlayer];
[localplayer authenticateWithCompletionHandler:^(NSError *error) {
    if (error) {
        //DISABLE GAME CENTER FEATURES / SINGLEPLAYER
    }
    else {
        //ENABLE GAME CENTER FEATURES / MULTIPLAYER
    }
}];
于 2010-12-08T19:36:29.920 回答