开发者

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

开发者 https://www.devze.com 2023-02-12 00:37 出处:网络
Waiting for Game Center authentication to complete is a bad id开发者_运维问答ea since it can take a very long time.Moreover, authentication is done not just at game launch but whenever you switch back

Waiting for Game Center authentication to complete is a bad id开发者_运维问答ea 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:

  • how do you resume a saved game if you don't know who the player is? Ideally, a saved game would be associated with who was playing so you don't have someone resuming another person's game.

  • how do you resume a game after an app switch back if you don't know who the player is (the player may have changed via the Game Center app)?

  • a Game Center log in alert might pop up in the middle of an action game (it is not paused)

  • what if the game is over before authentication completes? What if the initial authentication completes after a few games have been played? What if the initial authentication completes after an app switch or two (which in turn result in more authentications)?

What is a reasonable approach to handle these problems?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消