我正在尝试使用 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.}
有人知道出了什么问题吗?