AuthenticateWithCompletionHandler: Deprecated: Deprecated first in iOS 6.0

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

+7
source share
1 answer

Yes, you need to manually submit the login form to iOS6, this gives you more control over the presentation of the screen. Try

 localPlayer.authenticateHandler = ^(UIViewController *viewController,NSError *error) { if (localPlayer.authenticated) { //already authenticated } else if(viewController) { [self presentViewController:viewController];//present the login form } else { //problem with authentication,probably bc the user doesn't use Game Center } }; 
+10
source

All Articles