user625569
user625569

Reputation: 41

Game Center authentication can take a very long time. How to work around it?

Waiting for Game Center authentication to complete is a bad idea since it can take a very long time. Moreover, authentication is done not just at game launch but whenever you switch back to a game via fast app switching.

But not waiting for authentication presents problems:

What is a reasonable approach to handle these problems?

Upvotes: 2

Views: 3763

Answers (1)

xuanweng
xuanweng

Reputation: 1939

Hmm.. i only authenticate at the start of app.. Its set by yourself when you want to authenticate the player.. You might want to save the player alias when the player is first authenticated.. Means:

sharedData.myName =  [[GKLocalPlayer localPlayer]alias];

So when the player app switch and stuff, but is not authenticated, you save data under this player alias.. So when the player is finally authenticated, you send the data to GameCenter

Meaning in your checking GameCenter part..

if(!inGame)
{
  [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error){
        if(error == nil){
  if(sharedData.myName ==nil)
  {
    sharedData.myName = [[GKLocalPlayer localPlayer]alias];
  }
  else if([[GKLocalPlayer localPlayer]alias] == sharedData.myName)
  {
    [self sendSavedData];
  }
  else if([[GKLocalPlayer localPlayer]alias] != sharedData.myName)
  {
    // create new data or look for other saved data which has the same name..
    // set sharedData.myName to current player Name..
  }
}

enter code here

Upvotes: 1

Related Questions