Game Center Login Dialog Not Shown Again After Cancelling It for the First Time (Ios7)

Game Center login dialog not shown again after cancelling it for the first time (iOS7)

In regards to your comment, I found the Apple documentation that mentions Game Kit's policy of not asking a user to login again after they have cancelled login once.

It's in the Game Center Programming Guide under Common Tasks When Working with Players > Authenticating a Local Player on the Device. (bold type is mine)

Important: Game Kit handles opting out of Game Center across all games that support Game Center. If a player has already declined to create an account, when your game authenticates the player, it is told there is no authenticated player. The player never sees an authentication dialog. Because Game Kit handles this process across all games, your game should not include its own mechanism to disable Game Center authentication or ask a player’s permission to authenticate. Instead, your game should simply authenticate the player every time it launches and respond appropriately when authentication completes.

You can confirm this by including an NSLog in the authentication handler to show each time the handler is called and whether it succeeded or failed. Hope this helps...

Reenabling GameCenter after user-cancelled ios9

Regardless of whether you're using the deprecated method in the original post or the current preferred mechanism (as of this writing),

[[GKLocalPlayer localPlayer] setAuthenticateHandler:^(UIViewController *loginViewController, NSError *error)
{

}];

you only get one shot at authenticating. If you try setting the authentication handler again later, the login screen will not appear again. These links talk more about that:

  • Game Center login dialog not shown again after cancelling it for the first time (iOS7)
  • ios: programmatically ask for Game Center sign-in?

Killing the app (not just switch away, but actually close the app) and restarting it will cause the login to appear again when you attempt to authenticate. Alternatively, switching to the game center app should allow the user to log in.

So, in my app, I check the error code. If the user cancels, the error.code in the handler will be set to 2. When I see this value, I disable all game center functionality and I put up a notice to the user stating what they need to do to complete logging in.

Reenabling GameCenter after user-cancelled 3 times (iOS7 only)

General > Reset > Reset All Settings

Thats the only way I've heard of fixing it, hopefully Apple comes up with a more elegant way, because it's downright annoying and absolutely NOT user friendly.

In iOS 6, if you logged out and logged back into GC, it would be re-enabled. But that functionality was removed in iOS 7 for some reason.

Edit:

I read in another SO question, that this works properly (log-out, log-in re-enables GC) outside of a sandbox environment.

ios: programmatically ask for Game Center sign-in?

I'm assuming you're calling this GKLocalPlayer method on launch: -setAuthenticateHandler: (>= iOS7) or -authenticateWithCompletionHandler: (<= iOS6)

If the user cancels the presented login screen, calling these methods again does nothing, or rather, the completion handler is called with an error. The user will then need to login to GameCenter through the GameCenter app or through the Settings app. (While testing, you can login through the GameCenter app, then logout. After that the screen can be presented in your own app again.) You can show an UIAlertView telling the user to login through the GameCenter app.

Alternatively, and I don't know if this is allowed/approvable, but in iOS7 the authenticateHandler has a viewController parameter holding the login screen. If you store this login view controller in an instance variable and the user cancels login, you can present the login screen again later using a UINavigationController.

If you try to present the saved login view controller with -presentViewController:animated:completion: the view controller's Cancel button no longer works, but using a UINavigationController hides the Cancel button and allows navigation back to your own view controller.

You'll also need to hide the login screen manually after the user logs in by responding to GKPlayerAuthenticationDidChangeNotificationName. It doesn't seem like developers were intended to be able to do this, so it may not pass approval, but it works!



Related Topics



Leave a reply



Submit