gpt4 book ai didi

iphone - 无法验证本地播放器iOS6

转载 作者:行者123 更新时间:2023-12-01 16:50:44 27 4
gpt4 key购买 nike

我正在iOS6中构建Game Center游戏,并且不断遇到问题。当前的问题让我感到困惑-我的游戏每次尝试对本地玩家进行身份验证都会失败。每当它触发我的“禁用游戏中心”功能时,都会使我发疯。

- (void) disableGameCenter
{
// Write something to disable gamecenter.
// gameCenterAvailable = FALSE;
}

-(void)showAuthenticationDialogWhenReasonable:(UIViewController *)viewController
{
// Pause Tasks Here
// [[[(AppDelegate *)[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:viewController animated:YES completion:nil];
}

- (void) authenticateLocalPlayer
{
localPlayer = [GKLocalPlayer localPlayer];
__weak GKLocalPlayer* weakLocalPlayer = localPlayer;

weakLocalPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
{
if (viewController != nil)
{
[self showAuthenticationDialogWhenReasonable: viewController];
}
else if (weakLocalPlayer.isAuthenticated)
{
self.localPlayer = weakLocalPlayer;
}
else
{
[self disableGameCenter];
}
};
}

最佳答案

如果我错了,请原谅我,但我不认为您正在运行authenticate方法。

请尝试以下方法:

- (void) authenticateLocalPlayer
{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer authenticateWithCompletionHandler:^(NSError *error) {
if (localPlayer.isAuthenticated)
{
NSLog(@"Authenticated");
}
else
{
NSLog(@"Not Authenticated");
}
}];
}

关于iphone - 无法验证本地播放器iOS6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16126320/

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