Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authenticating the local player - Game Center - iOS6

I'm completely new to development in Game Center. I have watched the videos in WWDC and looked at the developer website. They suggest I enter code like this for iOS 6:

- (void) authenticateLocalPlayer
{
    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
         if (viewController != nil)
         {
             [self showAuthenticationDialogWhenReasonable: viewController
         }
         else if (localPlayer.isAuthenticated)
         {
             [self authenticatedPlayer: localPlayer];
         }
         else
         {
             [self disableGameCenter];
         }
     }];
}

I have copied this into the app delegate.m file, however it does not like it, showing errors like expecting a ] after [self showAuthenticationDialogWhenReasonable: viewController } amongst others.

Can anyone please tell me how to authenticate the user for game center in iOS 6?

like image 919
user1718770 Avatar asked Dec 06 '25 01:12

user1718770


1 Answers

To get an introduction to GameKit, there are samples available from apple, for example: https://developer.apple.com/library/ios/#samplecode/GKLeaderboards/Introduction/Intro.html.

In your code you are missing the closing "]", but of course you need more than just this function to connect to the gameCenter. Best start with one of the samples.

like image 89
palugu Avatar answered Dec 09 '25 01:12

palugu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!