title: Could not connect to the Game Center Server
body: <p>I am trying to integrate Game Centre to my Sprite Kit game. I am referring to this link: </p>
  
  <p><a href="http://www.appcoda.com/ios-game-kit-framework/" rel="nofollow">http://www.appcoda.com/ios-game-kit-framework/</a></p>
  
  <p>I have created a record on my iTunes Connect account for the game I am building. I try connecting to the Game Centre in the Simulator by trying to login through the Game Centre App itself and it gives me this error: </p>
  
  <p><strong>Could not Connect to the Game Center Server</strong></p>
  
  <p>And if I try to login through settings > Game Center, I get an error saying: </p>
  
  <p><strong>Unable to connect to server,<br>
  The network connection was lost</strong>  </p>
  
  <p>When I open my game, I have code written which checks if there is an authenticated user or not, and if not, it shows up the login to game centre scene. It showed this a couple of times but I canceled it because I kept getting the first error. Now that screen doesn't even show up.  </p>
  
  <p>What am I doing wrong?</p>
  
  <p>PS: I have Game Centre enabled in my game in the capabilities menu.</p>
  
  <p>EDIT:<br>
  This is in my viewController.m:  </p>
  
  <p>-(void)authenticateLocalPlayer {</p>
  
  <pre><code>GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
  
  localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
      if (viewController != nil) {
          [self presentViewController:viewController animated:YES completion:nil];
      }
      else{
          if ([GKLocalPlayer localPlayer].authenticated) {
              gameCenterEnabled = YES;
  
              // Get the default leaderboard identifier.
              [[GKLocalPlayer localPlayer] loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString *leaderboardIdentifier, NSError *error) {
  
                  if (error != nil) {
                      NSLog(@"%@", [error localizedDescription]);
                  }
                  else{
                      leaderboardIdentifier = leaderboardIdentifier;
                  }
              }];
          }
  
          else{
              gameCenterEnabled = NO;
          }
      }
  };   
  </code></pre>
  
  <p>}</p>
  
  <p>I call it in the viewDidLoad of my viewController.m</p>