I have the following code to authenticate local user in GameKit. There are no diagnostics and no crash but the handler is never used and the local user is never authenticated. Can some one say why? This way of authenticating is following the Wenderlich blog on Cocos2d. The ANNOUNCE and CCLOG lines are mine for debugging and they show that the method is called but the handler is not called. The redundant-looking BOOLs are also from debugging. I'm testing on an iOS6 iPhone. This code is in the AppDelegate.
-(void) authenticateLocalPlayer {
ANNOUNCE
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) {
[self setLastError:error];
if ( [CCDirector sharedDirector].isPaused ) [[CCDirector sharedDirector] resume];
CCLOG(@"inside authenticateHandler");
if (localPlayer.authenticated) {
_gameCenterFeaturesEnabled = YES;
X.localPlayerAuthenticated = YES;
} else if (viewController) {
[[CCDirector sharedDirector] pause];
[self presentViewController:viewController];
} else {
_gameCenterFeaturesEnabled = NO;
X.localPlayerAuthenticated = NO;
}
};
CCLOG(@"lastError: %@", self.lastError);
CCLOG(@"localPlayer.authenticated: %d", localPlayer.authenticated);
}