GameCenter scores are not being posted to the leaderboard

Hello!

Bare with me here, as there is a lot to explain!

I am working on implementing a Game Center high score leaderboard into my game. I have looked around for examples of how to properly implement this code, but have come up short on finding much material. Therefore, I have tried implementing it myself based off information I found on apples documentation.

Long story short, I am getting success printed when I update my score, but no scores are actually being posted (or at-least no scores are showing up on the Game Center leaderboard when opened).

Before I show the code, one thing I have questioned is the fact that this game is still in development. In AppStoreConnect, the status of the leaderboard is "Not Live". Does this affect scores being posted?

Onto the code. I have created a GameCenter class which handles getting the leaderboards and posting scores to a specific leaderboard. I will post the code in whole, and will discuss below what is happening.

PLEASE VIEW ATTACHED TEXT TO SEE THE GAMECENTER CLASS!

In a different GameScene, once the game is over, I request to post a new high score to Game Center with this line of code:
Code Block
GameCenter.shared.submitScore(id: GameCenterLeaderboards.HighScore.rawValue)

Now onto the logic of my code. For the longest time I struggled to figure out how to submit a score. I figured out that in Xcode 12, they deprecated a lot of functions that previously worked for me. Not is seems that we have to load all leaderboards (or the ones we want). That is the purpose behind the leaderboards private variable in the Game Center class.

On the start up of the app, I call authenticate player. Once this callback is reached, I call loadLeaderboards which will load the leaderboards for each string id in an enum that I have elsewhere. Each of these leaderboards will be created as a Leaderboard object, and saved in the private leaderboard array. This is so I have access to these leaderboards later when I want to submit a score.

Once the game is over, I am calling submitScore with the leaderboard id I want to post to. Right now, I only have a high score, but in the future I may add a parameter to this with the value so it works for other leaderboards as well. Therefore, no value is passed in since I am pulling from local storage which holds the high score.

submitScore will get the leaderboard from the private leaderboard array that has the same id as the one passed in. Once I get the correct leaderboard, I submit a score to that leaderboard. Once the callback is hit, I receive the output "Successfully submitted score to leaderboard". This looks promising, except for the fact that no score is actually posted.

At startup, I am calling updatePlayerHighScore, which is not complete - but for the purpose of my point, retrieves the high score of the player from the leaderboard and is printing it out to the console. It is printing out (0), meaning that no score was posted.

The last thing I have questions about is the context when submitting a score. According to the documentation, this seems to just be metadata that GameCenter does not care about, but rather something the developer can use. Therefore, I think I can cross this off as causing the problem.

I believe I implemented this correctly, but for some reason, nothing is posting to the leaderboard. This was ALOT, but I wanted to make sure I got all my thoughts down.

Any help on why this is NOT posting would be awesome! Thanks so much!

Mark
Post not yet marked as solved Up vote post of MDietrich Down vote post of MDietrich
3.1k views

Replies

Hi,

I'm having the same problem when using the new (not deprecated) GameKit API for submitting scores to an existing game which has leaderboards that are already live on the App Store (I'm working on the update ATM).

This has worked for me before (with the old API that is now deprecated) but it doesn't work with new API, same as you described: there's no any error reported, but submitted scores are not visible on Game Center, and when I load scores I always get the old ones.

Currently, I'm not sure if this is happening because of Debug configuration and it would magically start working when Release configuration is used (Test Flight or App Store release).

Also, I think that the new context parameter should be optional instead of required, so currently I'm just using -1 for that, but I also tried with 0 and that didn't have any effect regarding this problem.

If anyone could shed some light on this subject, I'm also interested, since by looking at the docs or related WWDC sessions it's just not clear why is this not working as it's supposed to. Is this a bug in the new GameKit API or we're using it wrong?
You're not the only one, many developers have mentioned (for at least a couple months now) that this release of GameCenter has a multitude of issues. I myself am not able to submit any leaderboard scores (even though no error is thrown)

As someone fairly new to Apple's technology, I probably would never again consider Swift/GameplayKit as a choice for a serious game. Maybe one day the core features will be corrected after Apple hires QA engineers?
I had the same problem, but for me it worked when using the class function GKLeaderboard.submitScores instead of the instance function on the leaderboard I wanted to submit to.


Same problem, I was able to use the GKLeaderboard.submitScores class function, but it only worked the first time. I can't post new scores and there is no error.
I believe the class function version of submitScores is for the class leaderboard while the instance version is for the recurring leaderboards. At least that's how I read their documentation.

Same issue here

"Before I show the code, one thing I have questioned is the fact that this game is still in development. In AppStoreConnect, the status of the leaderboard is "Not Live". Does this affect scores being posted?"

I'd be curious too, especially because there is a "Delete test data" button as well with a description "After testing your leaderboards, you should remove the leaderboard test data before submitting the app for review." that suggest it should work before the app is sent to review.

I'm using the class function version, no error returned, just silently nothing happens, no data in the leaderboard, neither in the Dasboard (triggered from tha Access Point) nor in AppStore Connect.