swiftgame-centergamekitgame-center-leaderboardgkscore

Does method report(_:withCompletionHandler:) send score even if your internet connection was lost?


I have a question about GKScore. There is a method called report(_:withCompletionHandler:). What happens if you lose your Internet connection. Do I need to save my score and submit it later? Or the method itself solves it. Is it not automatically sent in the background? Thanks in advance


Solution

  • From Apple's Game Center programming documentation:

    Your game should create the score object and report the score to Game Center immediately after the score is earned. This sets the date and time accurately and ensures that the score is reported correctly. If for some reason the score could not be reported because of a network error, Game Kit automatically resends the data when the network becomes available.

    So you don't have to do anything. Reference to the docs is here.