gpt4 book ai didi

iphone - Game Center localPlayer 始终经过身份验证

转载 作者:行者123 更新时间:2023-11-28 17:47:49 25 4
gpt4 key购买 nike

我正在尝试检测本地播放器身份验证是否有效,似乎我总是得到肯定的结果。

这是我使用的代码:

//--------------------------------------------------------------
- (void)authenticateLocalPlayer
{
NSLog(@"Authenticating local player %@ (%d)", ([GKLocalPlayer localPlayer].authenticated? @"YES":@"NO"), [GKLocalPlayer localPlayer].authenticated);
if ([GKLocalPlayer localPlayer].authenticated == NO) {
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
[self callDelegateOnMainThread:@selector(authenticationChanged:)
withArg:nil
error:error];
}];
}
}

//--------------------------------------------------------------
- (void)authenticationChanged:(NSError *)error {
if (error != nil) {
NSLog(@"Error authenticating local player: %@", [error localizedDescription]);
}
NSLog(@"Authentication changed %@ (%d)", ([GKLocalPlayer localPlayer].authenticated? @"YES":@"NO"), [GKLocalPlayer localPlayer].authenticated);
}

我在断开网络连接时测试了这段代码,这里是跟踪输出:

2010-12-13 13:20:59.799 LittleScreams[954:307] Authenticating local player NO (0)
2010-12-13 13:21:01.616 LittleScreams[954:307] Error authenticating local player: The Internet connection appears to be offline.
2010-12-13 13:21:01.621 LittleScreams[954:307] Authentication changed YES (1)

明明已经断线了,但是还在认证玩家!任何想法发生了什么?我在设备和模拟器中得到了相同的结果。

TIA

最佳答案

我认为您不应该手动调用 authenticationChanged,请查看 Game Kit Programming Guide 并按照对我有用的步骤进行操作。

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/GameKit_Guide/Users/Users.html

关于iphone - Game Center localPlayer 始终经过身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4432148/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com