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!