Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I check for Game Center authentication status outside my app?

I want to be able to know if the user running my app is connected to GameCenter (through GameCenter app or through other app), when i'm first running my app.

I found out that if I check the boolean:

[GKLocalPlayer localPlayer].authenticated)

it returns false. I guess one thing that might fix this is running at startup this:

[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error)

However, in case the user is not connected this brings the game center pop up which requests an existing account or creating a new one.

So my question is: is there a way to know my user connected GC outside of my app while my app was down, without popping up the above alert in case he is not connected ?

Thanks!!

like image 571
Idan Avatar asked Dec 22 '10 12:12

Idan


People also ask

How do I check my Game Center login?

To check if you are signed in to Game Center you should navigate to "Settings > Game Center", from this menu you can either create a Game Center profile, using an e-mail account of your choice, or log in to your existing account.

Is Game Center account linked to Apple ID?

When you sign in with your Apple ID, you will be signed in to Game Center automatically. Game Center allows you to engage in game-related activities such as participation in leaderboards; multiplayer games; finding, viewing, and challenging friends; and tracking achievements.

How do you authenticate Game Center?

Game Center also checks whether you configured your game for Game Center. To authenticate the user, set the authentication handler ( authenticateHandler ) on the shared instance of GKLocalPlayer that represents the player of your game as in: GKLocalPlayer. local.

Is Game Center connected to iCloud?

You can use iCloud and Game Center to keep your progress, high scores, and game saves up-to-date across your devices. If you're signed in to the same iCloud and Game Center accounts and download Apple Arcade games from the App Store on all of your devices, you can access your game saves and progress on all of them.


1 Answers

You can do it on iOS 6.0 or higher:

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
        if (viewController == nil && error == nil) {
            NSLog(@"Here, you know that the user has already signed to Game Center, whether in through your app or not.");
        } 
    };
like image 101
Mike Nathanson Avatar answered Sep 27 '22 18:09

Mike Nathanson