GKLeaderboard's localPlayerScore delay after saving a GKScore

96 views Asked by At

I'm trying to get a user's new leaderboard rank after scoring a high score and I found it takes about 5 seconds for the GKLeaderboard scores to update. I've tested the code against a Release build (from Xcode) and the delay is still there.

let score = GKScore(leaderboardIdentifier: leaderboardId)
score.value = Int64(highScore)
GKScore.report([score]) { _ in
    // Adding a 5 second delay here solves the problem.
    let leaderboard = GKLeaderboard()
    leaderboard.identifier = leaderboardId
    leaderboard.loadScores { _, _ in
        // leaderboard.localPlayerScore shows data from before saving the new score.
    }
}

Is there a way around this? The 5-second delay seems flaky. Maybe once the app is in the App Store this delay is no longer there? I could probably create a workaround by storing the scores before the user plays the game and locally calculate the new rank but the shared code should avoid the need for that, right?

0

There are 0 answers