我正在努力将回合制比赛集成到我的游戏中,几天前,我开始从 GameKit API 收到奇怪的错误,指出本地玩家未经过身份验证,尽管他已通过身份验证。
当我启动应用程序时,authenticateHandler
被调用,显示视图控制器,输入密码后,authenticaHandler
再次调用,本地玩家似乎已通过身份验证。isAuthenticated
回报YES
.
但一旦我开始使用任何 GameKit API,例如loadFriendsWithCompletionHandler:
,返回错误,表示玩家尚未通过身份验证。
这是处理身份验证更改的代码。
[[GKLocalPlayer localPlayer] setAuthenticateHandler:^(UIViewController *viewController, NSError *error) {
if ([[GKLocalPlayer localPlayer] isAuthenticated]) {
// Player authenticated
} else {
// Player not authenticated
if (viewController != nil) {
// Present view controller
}
}
}];
这是我在调用任何 GameKit 方法时收到的错误消息。请注意-isAuthenticated
返回错误时仍然返回YES。
查找匹配时出错:错误域=GKErrorDomain代码=6“请求的操作无法完成,因为本地玩家尚未经过身份验证。” UserInfo=0x14e9f950 {NSLocalizedDescription=请求的操作无法完成,因为本地玩家尚未经过身份验证。}
(lldb) print (BOOL) [[GKLocalPlayer localPlayer] isAuthenticated]
(布尔)$3 = 是
我正在游戏中心沙盒中进行测试,几天前就开始发生这种情况。以前,我根本没有遇到过这个问题。
当应用程序启动时,这种情况只会发生大约三分之一。我尝试过删除应用程序、重新启动设备、清理构建文件夹以及我能想到的所有其他内容。
我错过了什么或者其他人遇到过类似的问题吗?
这个有钱人苹果文档 https://developer.apple.com/library/ios/documentation/GameKit/Reference/GKLocalPlayer_Ref/Reference/Reference.html是一个值得一看的好地方。我建议有两件事 -
如果您的设备有,Game Center 无法完成身份验证
日期不正确。因此,请继续检查当前日期。
你可能已经这样做了。我相信你 - iOS 模拟器 >> 重置
内容和设置
您认为您的使用方式可能有问题吗-[GKLocalPlayer loadFriendsWithCompletionHandler:]
?您上面的身份验证功能没有任何问题,但如果它适合您,我很乐意分享我的 -
-(void)authenticateLocalPlayer{
// Instantiate a GKLocalPlayer object to use for authenticating a player.
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
if (viewController != nil) {
// If it's needed display the login view controller.
[self presentViewController:viewController animated:YES completion:nil];
}
else {
if ([GKLocalPlayer localPlayer].authenticated) {
// If the player is already authenticated then indicate that the Game Center features can be used.
_gameCenterEnabled = YES;
}
else {
_gameCenterEnabled = NO;
}
}
};
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)