Game Center setHighScore category?

I have switched from dual OpenFeint/GameCenter support to having Game Center only support for my iOS app.

The problem is that the gameNetwork.request( “setHighScore” ) call doesn’t appear to be setting any high scores.

On the documentation page: http://developer.anscamobile.com/reference/index/game-network/gamenetworkrequest a couple of other people have expressed similar issues.

My callback gets called, so it appears the call is “working”, however the scores do not get updated. The only thing I can think of is that the “category” parameter is not what I think it is.

For some unknown reason, this parameters name was changed from “LeaderboardID” to “category”. The Ansca documentation says this is “The nomenclature deviates in this case to provide consistency with our existing gameNetwork APIs”.

However, when you set up a Leaderboard om iTunes Connect there are only two fields that *could* be the “category”. Apple names these two fields:

“Leaderboard Reference Name”
“Leaderboard ID”

There is NOTHING named Category.

I am passing in the value I set in the “Leaderboard ID” field. This should be the correct value to use, but since my high scores are not posting there must be something wrong.

Here is the actual code I am using to set the high score:

[lua]local myHighScore = 1000

function highScoreCallback()
print( “High score should have been posted” )
end

gameNetwork.request( “setHighScore”,
{
localPlayerScore = { category=“9788861”, value=myHighScore },
listener=highScoreCallback
} )[/lua]

The 9788861 value is the string I am using for my “Leaderboard ID”. The reason I am using this instead of a reverse domain string is because it is the ID I get from OpenFeint. This allows me to keep my code consistent.

My current published app uses the dual openfeint/gamecenter approach and has NO problems setting high scores. I suspect the issue is when using the stand alone Game Center support. Either I have something wrong in the above call, or there is a bug when you opt not to use OpenFeint and just use Game Center.

Has anyone else run into this issue?

[import]uid: 16734 topic_id: 22769 reply_id: 322769[/import]

BTW, to answer some questions sure to come up:

  1. Yes, I am using a Sandbox Game Center account
  2. Yes, I logged out, and logged back in
  3. Yes, Game Center logs me in just fine when I launch my app.
  4. Yes, I have Enabled Game Center support in iTunes Connect
  5. Yes, my Leaderboards (I have 2 configured) show up in Game Center.
    [import]uid: 16734 topic_id: 22769 reply_id: 90851[/import]

The nomenclature is consistent with GameKit, not iTunes Connect. Blame Apple for this, not us.

https://developer.apple.com/library/ios/#DOCUMENTATION/GameKit/Reference/GameKit_Collection/_index.html#//apple_ref/doc/uid/TP40008303

“category” is the name of the property used in the GKScore class. Granted, we deviated a little here because in another API, we were forced to differentiate between the “localPlayerScore” and other player scores. “localPlayerScore” is what Apple used for that API so we stayed consistent with that.

Nowhere have I seen does Apple explain what “category” maps to in iTunes Connect. But I’ll solve the mystery for you. category is the Leaderboard ID and from what I can tell, Leaderboard Reference Name is never once used in the GameKit API so that field is completely worthless.
Your code snippet looks correct to me. Assuming everything else is correct that should work. Keep in mind that myHighScore must be better than your previous score or Game Center will ignore it. (You can never reset a score without clearing the board.) Apple doesn’t document any of this either.

I seem to need about a day for a score to materialize in the GUI leaderboard after I set it, though I only need about 5 seconds for it to appear using loadScores. Other users have reported you need at least 2 test accounts to see scores post in the GUI. I haven’t been able to confirm this.

We now have an automated test that runs through 477 tests on Game Center alone. We are currently running it on two different devices/OS’s nightly under different Game Center accounts. We have 7 leaderboards and try to set new highscores on multiple boards. While there could still be bugs, I have pretty good confidence that these APIs are working. (This is actually our most advanced and comprehensive automated test so to date.)

[import]uid: 7563 topic_id: 22769 reply_id: 90852[/import]

FYI, we have 5 test accounts for our automated test. Four are friends of each other, one is a ‘stranger’ and also our high score leader. So we haven’t tested with just two accounts a long while.
[import]uid: 7563 topic_id: 22769 reply_id: 90855[/import]

@ewing,

Thank you for the response.

I have two separate Game Center Sandbox accounts, I’ve tried both.

My value is greater than zero, so it should be added.

The only thing that makes sense is that it will show up tomorrow.

In the meantime I will try using the loadScores request and see if I can retrieve the correct values. At least if that works then I will know it is a time delay issue on having the scores posted.

BTW, I didn’t mean to come across like I was blaming you for the difference in naming LeaderboardID to category. I understand why you’ve used that nomenclature, but also a little confused as to why you’d say to blame Apple because that’s what they call it in their GKScore. Once again, I “get it”, but since Corona is a cross platform SDK, and since you don’t provide direct access to any platform specific API’s what does it really matter what Apple calls it? Wouldn’t it be better for people to have a consistent API in the Corona SDK? Just my two cents.

Ken [import]uid: 16734 topic_id: 22769 reply_id: 90853[/import]

Blame Apple for not using consistent names between their own APIs and iTunes Connect.

Game Center is effectively a ‘native’ API. It is not cross-platform. People wanted native Game Center, so we gave it to them. We felt by sticking to Apple’s terminology, it would allow people to cross reference with Apple’s documentation for more information (a good idea for native APIs) and also be familiar to anybody with experience with native Game Center coming to Corona.

[import]uid: 7563 topic_id: 22769 reply_id: 90857[/import]

@ewing,

Understood. You are using a different style of cross platform API abstraction than I am used to, but that’s Ansca’s decision to handle it as they see fit.

I don’t know the percent of your developers that actually do anything in XCode using Objective-C, but from the questions in the forums that I have read (and many that I have answered) it appears you have a LOT of developers that know nothing of low level API’s and don’t care to.

They enjoy the hardware and software abstraction that Corona offers (it’s greatest strength IMHO) and don’t care what the underlying technology is as long as they can make cool apps.

If what I am guessing about the makeup of your developers is right, then having a single consistent API would be more appealing; whenever it makes sense.

Obviously, if a particular platform has functionality that doesn’t exist (or is radically different) on another platform you can’t really do this.

Still, naming a field “LeaderboardID” seems like a safe, consistent and easy to use approach; especially since this is the term used in the field that people will have to fill out to set up their Game Center Leaderboards. Only programmers interested in the underlying Objective-C interface will care that it’s called “category” in the GKScores API.

Once again, I am not flaming anyone; you are free to implement it as you see fit. I just thought that you might want to hear another opinion on this, one based on 30 years of cross platform development experience.

Bottom line for people who have wading through my ramblings and your succinct responses: The “category” parameter is the “Leaderboard ID” field in iTunes Connect. [import]uid: 16734 topic_id: 22769 reply_id: 90861[/import]

You might have a point on this one. There are so many properties in Game Center it is easy to lose track. The other thing about Game Center is that the APIs were designed to feed into another. A table you get back from one call is designed to be fed directly into another call. [import]uid: 7563 topic_id: 22769 reply_id: 90893[/import]

@ewing,

That makes sense (one table feeding into another), but since this is just the Corona Dev name for that variable it doesn’t matter what you call it.

Really, I am 100% fine with it being named ‘category’. None of my posts would have been here if the doc for the request function had just said that iTunes Connect calls it “Leaderboard ID”. As you can see from other people on the doc page, they were confused too.

BTW, I gave your suggestion a try. I called the request loadScores and sure enough I was able to retrieve the scores I had posted even though they weren’t visible in the Game Center Leaderboards.

Thanks for that suggestion; very helpful and I am sure that other people who run into the same issue with the delayed posting of scores will find this to be a good way to verify there data was posted correctly. [import]uid: 16734 topic_id: 22769 reply_id: 90896[/import]

Ewing, Ken,
* we are close to submitting our game (free and paid) to Apple. The only thing holding us back is putting the final touches to game center functionality/handshake e.g. for updating scores/achievements when playing offline.

* to test our code with ad-hoc users we need to delete the test data in iTunes connect to start from scratch when we have a new build.
I reset the leaderboard in iTunes connect and as you can’t reset the achievements there I reset them via the game when it is a new build.

* I still don’t understand the conditions needed for the leaderboard to reset properly. Sometimes it resets immediately, sometimes never. Sometimes it disappears for some hours and then comes back with the same old numbers.
Do we need to be connected to GC or not while the board is being reset? does the old build need to be deleted from the ipad or not? does everyone need to be off the board or not/have the old build deleted or not while the board is reset?

* Also sometimes I have the impression that some reporting happens automatically if I had played offline (iOS5.1)but had played at least once online with a particular build. My commands seem to be repeated even though called only once.

Do you have any insight into this?
thanks, Luciane [import]uid: 32063 topic_id: 22769 reply_id: 93059[/import]

Hit reset on iTunes Connect. Don’t set any new scores for like 24 hours. You’ll see the boards come and go. Presumably there are multiple Apple servers and it will take time for them to all sync up. [import]uid: 7563 topic_id: 22769 reply_id: 93089[/import]

Thanks. Will try waiting. It’s a long wait time when you want to quickly test a new build. [import]uid: 32063 topic_id: 22769 reply_id: 93095[/import]

Think my problem may be related to this so didn’t want to start a new thread.

I’m attempting to send GC a score with the following code:

 gameNetwork.request("setHighScore",   
 {   
 localPlayerScore = { value=totalScore, category="737467"}  
 })  

But I’m getting the following error every time:

Lua Runtime Error: lua_pcall failed with status: 2, error message is: setHighScore for gameNetwork/Game Center could not convert your table to a GKScore object. Please verify you supplied the correct fields and value types.

A print of totalScore reveals it’s the number that it should be, while the string in category is the number I entered into iTunes Connect.

Any help/advice would be extremely appreciated…

Many thanks [import]uid: 33275 topic_id: 22769 reply_id: 95456[/import]

@SegaBoy,

Make sure you have your require statement and then try this:

[lua]gameNetwork = require( “gameNetwork” )

function highScoreCallback( event )
print( “High score should have been posted” )
end

gameNetwork.request( “setHighScore”,
{
localPlayerScore =
{
category=“737467”, value=totalScore
},
listener=highScoreCallback
} )[/lua]

I know the docs say the listener is optional, but I had similar problems when I didn’t have it in as a parameter. Also, make sure your “totalScore” value is a integer, not a string. [import]uid: 16734 topic_id: 22769 reply_id: 95491[/import]

I dunno. I’m doing everything you say and I am also getting no results. The info looks like it goes in but when I call loadScores, there is no data. Should I just wait until tomorrow and see if it shows up? [import]uid: 22392 topic_id: 22769 reply_id: 95599[/import]

Oh, I thought you were getting an error.

If the issue is that you aren’t seeing the scores then that is just because Apple can take up to 24 hours for leader board scores to show up. [import]uid: 16734 topic_id: 22769 reply_id: 95602[/import]

No thats SegaBoy, I just jumped in because I’ve been pulling my hair out all day trying to do this and found this thread. I wish it was mentioned somewhere that it could take 24 hrs to show up.

I’ve read the ansca docs and the apple docs and I didn’t see that info. Would’ve saved me a few wasted hours.

Is that also the case when the app goes live? It takes up to 24 hrs?

Anyway, thanks for your help [import]uid: 22392 topic_id: 22769 reply_id: 95605[/import]

@ChunkyApps,

Sorry, I am using my phone to try and help and didn’t see it was not a post from SegaBoy.

I know what you mean about wasted hours. I did the same thing for hours, finally found a post in the forums that said to wait and that seemed to be the issue.

Once an app is live scores seem to post within an hour or two. [import]uid: 16734 topic_id: 22769 reply_id: 95607[/import]

Sure enough, I checked before I went to bed and my scores were both there.

Thanks for the help Ken! [import]uid: 22392 topic_id: 22769 reply_id: 95726[/import]