Created
December 18, 2012 12:42
-
-
Save sdabet/4327634 to your computer and use it in GitHub Desktop.
Game Center authentication for both iOS 5 and iOS 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) authenticateLocalPlayer | |
{ | |
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; | |
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) { | |
// iOS 6 | |
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){ | |
if (viewController != nil) | |
{ | |
[navController_ presentViewController:viewController animated:false completion:nil]; | |
} | |
else if (localPlayer.isAuthenticated) | |
{ | |
// [self authenticatedPlayer: localPlayer]; | |
} | |
else | |
{ | |
// [self disableGameCenter]; | |
} | |
}; | |
} else { | |
// iOS 5 | |
[localPlayer authenticateWithCompletionHandler:^(NSError *error) { | |
if (localPlayer.isAuthenticated) | |
{ | |
// Perform additional tasks for the authenticated player. | |
} | |
else { | |
} | |
}]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment