iPhone模拟器6.0无法以沙箱模式连接到游戏中心

我正在尝试实现一个针对iOS 6的游戏中心感知应用程序。为了给出一些关于环境的信息,我正在使用XCode版本的mac os 10.7.5上运行4.5.2,xcode运行iphone和ipad模拟器版本6.0。 问题是我无法通过ipad或iphone模拟器连接到沙盒模式的gamecenter,但是在我的iphone中测试时,相同的代码可以正常工作。

我按照apple开发人员库中的gamecenter编程指南进行了操作,我从appdelegate的applicationDidFInishLaunching中调用它:

- (void)authenticateLocalUser:(UIViewController *)currentViewController { if (!gameCenterAvailable) return; GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){ if (viewController != nil) { [currentViewController presentViewController:viewController animated:YES completion:nil]; } else if (localPlayer.isAuthenticated) { NSLog(@"Player authenticated"); } else { NSLog(@"Player not authenticated"); } NSLog(@"Error: %@",error); }; } 

它输出:

 Error: Error Domain=GKErrorDomain Code=2 "The requested operation has been cancelled." UserInfo=0x8690510 {NSLocalizedDescription=The requested operation has been cancelled.} GKSConnSettings: set server: { "gk-cdx" = "17.173.254.218:4398"; "gk-commnat-cohort" = "17.173.254.220:16386"; "gk-commnat-main0" = "17.173.254.219:16384"; "gk-commnat-main1" = "17.173.254.219:16385"; } 

我已经尝试过主机文件修复虽然我的操作系统不是10.8.2,但它没有帮助。 https://devforums.apple.com/thread/168811?tstart=0

知道可能的原因是什么?

编辑:嗯,事实certificate,以GKSConnSettings开头的输出部分并没有表明任何问题,这是连接到游戏中心时的常规输出,正如我从互联网上读到的那样理解。 我在身份validation块中打印了实际的错误消息(GKErrorDomain = 2 …)。

我从以下网站获得灵感: https : //stackoverflow.com/a/8115807/837244 ,并决定使用不同的代码登录游戏中心帐户。 所以在viewdidload中我通常会调用:

 [[GCHelper sharedInstance] authenticateLocalUser:self]; 

现在我评论说,通过以下URL方案访问游戏中心,登录到我的帐户,然后注销。

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]]; 

最后通过评论URL代码并使用原始代码来恢复。 现在它工作正常,我想问题是游戏中心帐户已经在模拟器中连接,它拒绝了每个登录请求bc。 希望苹果更清楚地发现错误消息,花了一个月的时间来修复这么简单的问题,这可能对其他人有所帮助。

我知道这个问题引用了特定的Xcode和iOS模拟版本,但是如果你的模拟器已经登录了一个帐户,并且你不介意丢失你在模拟器上获得的任何数据(可能很小,但你永远不知道),您只需重置其上的设置和数据即可。

转到:模拟器 – >重置内容和设置…

…并在出现提示时确认操作。

对于运行iOS 9.x模拟器的Xcode7.x来说,这当然是正确的,其他人可能能够validation它是否适用于早期版本(特别是因为我发现了一个很老的问题和答案)。

Animal451

Necrothreadomancy:+1