I'm having some seriously confusing Game Center problems.
My app runs on iOS 6 and above only, and I've been using the standard code for authenticating with Game Center:
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController,
NSError *error) {
// Respond to authentication (failure or success) here!
}
With this code, the app has been running beautifully and without issue for weeks, for myself during development and with ~10-15 beta testers in ad hoc distributions.
For most of this time, and for most users, the app behaves as you expect: if you aren't logged into Game Center when the app launches, or are logged into a production Game Center account, the app prompts you (with the modal Game Center-themed View Controller) to log in with a Sandbox account. You log in to your sandbox account, and everything Just Works.
For a few users, though, something very strange has begun to happen.
The authenticateHandler
code is called, error
is nil
, but [GKLocalPlayer localPlayer].authenticated
is NO
, and the user is not logged into Game Center. Most important, there is no modal Game Center dialog to prompt the user to log in. The app simply launches, the authenticateHandler
code is called, but no authentication takes place. I think the app would work if the Game Center app would allow me to log in with my sandbox account, but it doesn't: logged in or out of my production Game Center account, there is no sandbox log-in option.
Since this only happens to some users, and has only begun to happen for my development device, I very much doubt that it's a problem with my code, and am guessing it is some complex interplay between iTunes Connect, provisioning profiles, Game Center's settings and history on the device, etc.
Game Center is enabled in our App ID and in iTunes Connect (and App IDs for both match).
Help!
Edit
My problem may be similar to iOS Development: Strange problem with authenticating Game Center user. The solution proposed for that question was to sign in manually in the Game Center app. This seems like a sensible solution, but I need to log in to the sandbox environment, and I can't find a way to get a sandbox Game Center login prompt in the Game Center app.