Stuck trying to get Game Center Leaderboard to work

I am trying to get a gamecenter leaderboard to work, but have gotten stuck. I am testing on the Xcode simulator because I was having trouble logging in to our sandbox account on a device. I am able to login to the sandbox account through the game using the init function, but the leaderboard does not show up in gamecenter. Under games it shows our game but underneath it says “No leaderboards or achievements”. I have set up a leaderboad in itunes connect, and have requests to setHighScore in the code that seem to be working. Here is the relevant code: 

local function updateCallback(e) local data = json.encode( e.data ) -- show encoded json string via native alert native.showAlert( "e.data", data, { "OK" } ) end --[[Update the gamecenter learderboard for gamescore.]]-- function [app name]GameNetwork.updateGamescore() --Sets the score if it is higher than the one on Apple's server gameNetwork.request( "setHighScore", { localPlayerScore = { category = "com.[domain].[game].gamescore", value = gamescore }, listener = updateCallback }) end

As expected the update callback displays {“value”: 25,“category”:“com.[domain].[game].gamescore”} when the updateGamescore function is called. Am I missing something? Any good tutorials on the gamenetwork api?

Cross-posted to stackoverflow

Still haven’t solved this problem…

I just put a bounty on the Stackoverflow question.

If its like the way it was the last time I tested an app, you have to have at least two score in the leaderboard from two different test apps before it will show up in sandbox.

Rob

We’ll give that a try, thanks!

We had no luck trying with two different accounts both for Gamecenter and Google Play game services. Any other ideas?

I had a problem where my version in iTunes Connect for the app didn’t match the version I was installing using my ad hoc distribution profile.  The difference was like this:

iTunes: 1.0 (from back when i initially added it to iTunes Connect)

My ad hoc version: 1.069

I changed my ad hoc version to 1.0, rebuilt and reinstalled, and suddenly my achievements started working.  I still don’t have leaderboards showing up, but from what I’ve read, it can take up to 24 hours for Leaderboard data to show up in the Sandbox Game Center.  So I’m hoping that now that I’m using the same app version, and I’ve had two test users play the game and set a score, that all will be well soon.

Dave

We had another thread this morning where for leaderboards, you have to create a 2nd apple ID, log your device in with that ID and set the score from it.  It cannot be your developer AppleID.

Rob

Thanks so much for posting this, we’ll give it a try. I am almost certain the version code is different so that may be the problem, I’ll post an update in a day or so.

We are using two separate sandbox accounts different from our Apple ID.

I just wanted to add that my leaderboards are _ still _ not showing up.  Achievements are working fine, though.  I created two entirely new test user accounts inside the sandbox in the iOS simulator, then used those to post scores. I added a print and checked the console log and the callback after setHighScore is being hit.

If you get back data in that setHighScore callback does that truly mean that it worked?

I’d like to verify something else with you guys because I see conflicting reports across the interwebs.  Do I need to explicitly specify the CFBundleIdentifier in the build.settings, or will Corona now grab it from my Provisioning Profile?

Another question I have is about how the high score system works. Do you think it will *only* show the score in the leaderboad if it’s better than the previous one? I assumed that if posted a score of 1000, and then someone else posted a score of 900, that both scores would show up, but now I’m wondering if that’s the case… There’s just so much mystery around how the Game Center (and Sandbox mode) works.

One last thing – for this to all work correctly for testing – do I have to build using an Ad Hoc Distribution Profile?

Thanks for any help.

Also, I’m using the latest Public Release and not a Daily Build because I’m not quite ready to switch everything to the new Composer framework yet. Would that have any effect on this by chance?

You know what – I added a 2nd leaderboard to the app, and it all started working. :-o

Glad you figured that out.

Rob

I would like to know the answer to this question as well, as I have been operating under this assumption, that my code was working because I was getting data back from the setHighScore callback.

Also, do we have to use our App Store provisioning profile or can we use an ad hoc test, or development provisioning profile?

Interesting… I wonder why that would fix it. I’ll give it a shot. Did you make any other changes at the same time that may have changed something as well?

I just added the new leaderboard, but i do have an answer on the question about “If you get back data in that setHighScore callback does that truly mean that it worked?”  –  I tried submitting scores to an invalid leaderboard, and it still sent me data like everything was great.

So you might also want to doublecheck your leaderboard id.

Dave

Awesome, thanks I’ll give those two ideas a shot.

Finally figured it out.  The issue was with the app id. Our ad hoc provisioning profile had a wild card, while our app store one did not. I created a new adhoc provisioning profile with the specific app id, and the leaderboards showed up immediately. Also our adhoc provisioning profile was using a different certificate than the app store certificate, so that may have been the issue as well.

Still haven’t solved this problem…

I just put a bounty on the Stackoverflow question.