我正在尝试使用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.}
任何人都知道出了什么问题?
解决方法
我发现连接到Game Center时遇到的一个问题是您的日期可能在设备上出错.检查您的日期是否是实际当前日期.不知何故,Game Center不允许来自日期不正确的设备的连接.