Reputation: 71
I've got an iPhone game that I've just added GameCenter support to, and everything seems to be working ok. But, as someone who doesn't use GameCenter, I've added an option so that users can turn it off. The only problem is that once the GKLocalPlayer is signed into GameCenter, I can't see a way to sign them out - which means that if the user is signed in, then disables GameCenter support, my app won't use it, but the GK library still signs the user back in every time my app comes back to foreground, until the app is terminated. I don't want this to happen!
Is there any way to log the local player out of GameCenter, or at least stop the GK framework from logging you back in every time your app becomes active?
Upvotes: 4
Views: 5015
Reputation: 1150
There's no way to log out of game center from within the app. The best solution is to add a boolean flag indicating the user's login status:
BOOL gameCenterOn = [[NSUserDefaults standardUserDefaults] boolForKey:@"gameCenterOn"];
Default it to YES, and just set it to NO if the user opts out of game center in your app.
You'll also have to check the value of that flag before processing any game center requests. (Including the [GKLocalPlayer localPlayer] authenticateWithCompletionHandler:
calls in the app delegate.)
Upvotes: 1