I am working on a game that uses Game Center, and I receive the following warning;
... 'authenticateWithCompletionHandler:' deprecated: deprecated first in iOS 6.0
Ok, I searched and found out that there is a new code for Local User authentication, so I replaced
old code:
- (void)authenticateLocalUser { if (!gameCenterAvailable) return; NSLog(@"Authenticating local user..."); if ([GKLocalPlayer localPlayer].authenticated == NO) { [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:nil]; } else { NSLog(@"Already authenticated!"); } }
with new:
- (void)authenticateLocalUser { if (!gameCenterAvailable) return; NSLog(@"Authenticating local user..."); if ([GKLocalPlayer localPlayer].authenticated == NO) { GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; [localPlayer setAuthenticateHandler:(^(UIViewController* viewcontroller, NSError *error) { //[localPlayer authenticateWithCompletionHandler:^(NSError *error) { OLD CODE! if(localPlayer.isAuthenticated) { //do some stuff }else { // not logged in } })]; } else { NSLog(@"Already authenticated!"); } }
and everything is fine, except for one. If the user is not registered, there is no login form in the Game Center. With the old code, it shows the login form in the Game Center if the user is not logged in.
Is there any additional code I have to add or something else?
Additional information: - landscape mode - deployment target: 6.0
Croios
source share