我是iOS新手,嘗試編寫一款有趣的基於回合的iOS遊戲。我試圖現在驗證本地用戶,並且在構建代碼時(儘管存在保留週期警告),但它始終無法通過GameCenter進行身份驗證。setAuthenticateHandler未能通過遊戲中心進行身份驗證
// Authenticate the local user.
- (void)authenticateLocalUser
{
if (!gameCenterAvailable) return;
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer setAuthenticateHandler:(^(UIViewController* viewcontroller, NSError *error)
{
//[localPlayer authenticateWithCompletionHandler:^(NSError *error) { OLD CODE!
if (localPlayer.isAuthenticated)
{
// Do some stuff.
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"NOT AUTHORISED"
message:@"YOUR'RE NOT LOGGED INTO GC."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
)];
}
我的舊代碼仍然有效,但在貶值iOS6的:
NSLog(@"Authenticating local user...");
if ([GKLocalPlayer localPlayer].authenticated == NO)
{
[[GKLocalPlayer localPlayer]
authenticateWithCompletionHandler:nil];
}
else
{
NSLog(@"Already authenticated!");
}
有什麼建議?
可能的重複http://stackoverflow.com/questions/13511030/login-in-iphone-app-via-gamekit – lostInTransit 2013-04-10 05:27:53
這不是一回事,可悲的是。 – 2013-04-10 05:40:51