Authentication Error in Game Center

I am trying to call the authentication method in the game center, but the authentication screen does not appear and the callback returns with the error: "The requested operation was canceled."

Code:

[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) { NSDictionary *userInfo = nil; if (error == nil) { NSLog(@"Game Center successfully authenticated"); } else { userInfo = [NSDictionary dictionaryWithObject:error forKey:@"NSError"]; } [[NSNotificationCenter defaultCenter] postNotificationName:Notification object:self userInfo:userInfo]; }]; 

Any idea what might cause this problem?

+4
source share
2 answers

In iOS 4.2, when a user cancels logging into Game Center, an error is returned after 3 attempts. You can fix the error by logging in using the Game Center application, and then try your application again, you should see a welcome message from Game Center in your application.

+17
source

You should do something like this after you have tested if the game center is available on a specific device:

 GKLocalPlayer *localplayer = [GKLocalPlayer localPlayer]; [localplayer authenticateWithCompletionHandler:^(NSError *error) { if (error) { //DISABLE GAME CENTER FEATURES / SINGLEPLAYER } else { //ENABLE GAME CENTER FEATURES / MULTIPLAYER } }]; 
-1
source

All Articles