게임 센터를 통해 플레이어를 인증해야합니다. 나는 그럭저럭 할 수 있었다. 그러나 그것은 일하는 것을 그만 뒀다. 이제는 항상 "viewController = nil"을 얻었고 localPlayer가 인증되었는지 검사 할 때 항상 false를 반환합니다.GameCenter를 통해 플레이어를 인증하는 방법
-(void)authenticateLocalPlayer{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
if (viewController != nil) {
[_spriteViewController presentViewController:viewController animated:YES completion:nil];
} else {
if ([GKLocalPlayer localPlayer].authenticated) {
NSLog(@"authenticated");
_gameCenterEnabled = YES;
// Get the default leaderboard identifier.
[[GKLocalPlayer localPlayer] loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString *leaderboardIdentifier, NSError *error) {
if (error != nil) {
NSLog(@"%@", [error localizedDescription]);
} else {
_leaderboardIdentifier = leaderboardIdentifier;
}
}];
} else {
NSLog(@"not authenticated"); // This is always triggered
_gameCenterEnabled = NO;
}
}
};
}
내가 뭔가 잘못하고 있는가 :
이것은 내가 뭘 무엇인가? 어떤 일을해야합니까/먼저 이것이 작동하는지 확인하십시오.
여기에서 토론을 읽었습니까? https://developer.apple.com/library/ios/documentation/GameKit/Reference/GKLocalPlayer_Ref/Reference/Reference.html#//apple_ref/occ/instp/GKLocalPlayer/authenticateHandler? 플레이어가 Game Center를 통해 인증 할 수 있도록 처리기로 전달 된보기 컨트롤러를 제시해야합니다. –
이유가 무엇인지 알려지지 않았습니다. 방금 수정했지만 viewController는 nil입니다. 왜 이것이 일어날 수 있습니까? – lisovaccaro
메인 스레드에서이 모든 것을 호출하는지 확인 했습니까? – lukaswelte