Take the 2-minute tour ×

imagine there is no internet connection when user is playing. The score cannot be submitted to game center. However I save the highscore on the phone using NSUserDefaults too.

So when the user plays next time and is connected to game center should I sync this score he achieved playing "offline"?

Is that a good practice?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

Per the Apple Game Center docs, the answer is YES.

Make Sure Your Game Sends Data Again After a Network Failure

When you implement leaderboards or achievements, your game reports a player’s scores or achievement progress to Game Center. However, networking is never perfectly reliable. If a networking error occurs, your game should save the Game Kit object and retry the action again at a later time. Both the GKScore and GKAchievement classes support the NSCoding protocol, so your game can archive those objects when it moves into the background.

Set up a cache that keeps your score data (I use NSUserDefaults) to preserve data between sessions, and every so often (like, each time the user enters the app) test to see if Game Center is reachable, and if so, upload your cached scores. Let me know if you need any code - this post is pretty old, so I won't be surprised if no one ever answers :)

share|improve this answer
add comment

Also per the Apple docs for iOS 5.0 and later network error related issues are handled by a background reporting task so the developer does not need to write anything to handle this if not supporting previous iOS versions.

(from GKScore Class Reference for method reportScoreWithCompletionHandler:)

If the error is a network error and your game is running on iOS 4.3 or earlier, your game should periodically attempt to report the progress until the score is successfully reported. On iOS 5.0 and later, the background reporting task automatically handles network errors on your game’s behalf.

I am not sure what is supposed to happen if no one is logged into Game Center at all though (no network related/ submission issues) when a high score is achieved and then someone logs in later. In that case no GKScore object can even be created because there is no authenticated player and so there is no way to know who actually achieved the score whenever the next person logs into Game Center. Seems handling logged in (even without a network connection temporarily) is best practice but if no one is logged in at all and a high score is gained then it's just tough luck because it is not known who earned it, other than saving it as a device high score. If anyone handles that case then please tell.

share|improve this answer
add comment

Good question.
In my point of view, if a user is offline and is still playing, the score he/she scores should be saved locally. And when he/she again appears online, the offline score shouldn't be submitted online. Because if offline score is submitted, the purpose of making the game online is defeated.

share|improve this answer
My personal opinion is that if the user log out from Game Center, those scores schooled not be submitted. On the other hand, if the user have no network connection, those scores should be stored locally and synced once the network connection is up again. Otherwise all your scores achieved in subways and flights would be lost. –  Structurer Sep 1 '11 at 4:14
add comment

Your Answer


