gameNetwork.request("setHighScore") does not work on iOS. GameCenter bug?

Hi @torbenratzlaff,

This is odd. I assume you did what the user(s) in that other thread did? As in, logging completely and totally out of GC, quitting the app on your device, and then restarting? Perhaps even power off and on the device before that?

Brent

Hey @Brent,

I did that as well, except powering of the device.

I will check that.

Thanks so far.

Torben

Got that same problem here. I’m testing on iPhone 4S, iPhone 5c and iPad.

The first score was sent without problem, but the second (higher than the first one) was not sent.

Hi @Wiler Jr,

This may be a bug then. Can you trim this down to a very basic sample project and submit it to the bug reporting system?

http://developer.coronalabs.com/content/bug-submission

Thanks,

Brent

Sure, Brent.

This bug is almost blowing my mind.

This is the last feature I’m trying to fix before submitting my game to Apple. I hope it doesn’t last any longer… Please. haha

Some success there, @torbenratzlaff?

Unfortunetly not.

I now submitted my app without this feature and will implement it with an update.

I experienced the same as you, first score was tracked correctly, all following were ignored.

Hello,

Did anybody file a bug report on this? Engineering will really need that before they can prioritize an investigation and see what’s going on.

Thanks,

Brent

I’m waiting for a new reply from Tom. He tried one of the codes I tried using and said it was not working (regarding the submission of posterior highscores) because of a boolean condition I had been using. The last e-mail I sent him, I told him to remove the boolean conditions to see if it works, because I had no success here, with it or without.

Hi @Wiler Jr,

Can you post the bug case # here for my reference?

Sure, Brent. Case 38550.

So, Brent, is that a Corona bug or something wrong within the code I’m using?

Hi @Wiler Jr,

I just checked out the bug report. Is there any way you can submit another sample project that clearly shows this issue occurring, and doesn’t rely on any reading of strings from a “bestscore.txt” or otherwise? Basically, to fully diagnose this issue, we’d like to see your code simplified and tuned down to the core problem that you’re reporting.

Thanks,

Brent

I’ve just sent the code within a .rar to the same e-mail I received from Corona Support.

I’ve removed the loggedIntoGC variable and, for the “bestscore.txt” issue, I’ve put an instruction about changing the variable manually to a higher value after submitting the previous one and then be sent again.

There’s nothing more I can change besides the loggedIntoGC and the instruction to what to do, for it’s the almost same code I use to submit the highscores and open the leaderboards right afterwards. The difference between it and my real code lies on the finalScore that has to be changed manually instead of the one the player scores and is stored within the “bestscore.txt” file and on the matter that I don’t specify my leaderboard ID once you don’t have my game’s CFBundleIdentifier and .mobileprovision file generated by Apple (and I think you don’t even need it if it’s a Corona bug, right?).

Note: GPGS presents no problem concerning the submission of scores stored within “bestscore.txt” file.

Hi @Wiler Jr,

I’m looking at your code now, and I still don’t see how you’re ever submitting a “higher score”. You basically initialize GC, you submit a high score of 50, and that’s it… you never submit anything higher than 50, so the expected behavior is that GC does nothing beyond this.

Also, are you sure that “event.data” is true within your “initCallback()” listener function?

I’m currently doing a little of my own testing on GC using my own code, and I’ll let you know if I can diagnose anything related to your issue.

Thanks,

Brent

Within the code of my game, the “bestscore.txt” stored score is changed whenever the player scores a higher one. In the instructions within the last code I sent, I suggest changing the value 50 to a higher one after submitting it to see whether it works or not.

Hi @Wiler Jr,

Does your code work when you test it in the Game Center “sandbox” mode? In my testing, updating scores through the sandbox mode works perfectly, and I can see them instantly updating as I submit higher scores.

Brent

Yes, @Brent. We are testing in the Game Center with “sandbox mode” enabled. May I see the code you’re using? I think @torbenratzlaff might be in need of it as well.

Hi @Wiler Jr,

I did some more testing and everything seems to be working for me. I set up a very basic increment of a score which is assigned to a Composer variable (so basically, it’s just known throughout my code because it’s part of the core Composer table). This simply uses a standard button – widget.newButton() or whatever you want – to increment the score by 25 on each tap. When I do this, I’m seeing the result update instantly in Game Center, and it shows in the Sandbox leaderboard.

[lua]

local composer = require( “composer” )

– Create a Composer variable named “currentScore” with value of 0

composer.setVariable( “currentScore”, 0 )

– Listener function for submission of high score

local function setHighScoreListener( event )

    print(“setHighScore-----------------------------------------------------------”)

    print_r( event )

end

– Button handler function

local function handleButton( event )

    – Increment “currentScore” by 25

    composer.setVariable( “currentScore”, composer.getVariable( “currentScore” ) + 25 )

    – Submit new “currentScore” to Game Center leaderboard with ID of “1” in iTunes Connect

    gameNetwork.request( “setHighScore”,

        {

            localPlayerScore = { category=“1”, value=composer.getVariable( “currentScore” ) },

            listener = setHighScoreListener

        }

    )

end

[/lua]

A few notes:

  1. For “localPlayerScore”, the “category” of “1” is my leaderboard ID within iTunes Connect. Obviously this should be a more descriptive name, but I’m using that for testing.

  2. In the “setHighScoreListener()” function, the “print_r” function refers to that shown in the tutorial on printing table contents. I really suggest you use this, as it will dig deep down into a table and all of its sub-tables to show you the values, and that’s especially important for things like Game Center where tables usually have various child tables, and values within those tables which you’ll need to check. LINK: http://coronalabs.com/blog/2014/09/02/tutorial-printing-table-contents/

So, please see if your code compares to this. It’s really simple and it works fine for me.

Thanks,

Brent

There goes the code I tested.

function new() local widget = require("widget"); local gc = require("gameNetwork"); local localGroup = display.newGroup(); local function onSystemEvent( event )     if(event.type == "applicationStart") then        gc.init("gamecenter");        return true    end end Runtime:addEventListener( "system", onSystemEvent ) local composer = require( "composer" ) -- Create a Composer variable named "currentScore" with value of 0 composer.setVariable( "currentScore", 0 ) local text = display.newText("0", 0, 0, native.systemFontBold, 20); localGroup:insert(text); local function showLeaderboards() gc.show("leaderboards", { leaderboard= {category="winners", timeScope="AllTime" }}); end -- Listener function for submission of high score local function setHighScoreListener( event )    print("setHighScore-----------------------------------------------------------")    print\_r(event) end -- Button handler function local function handleButton( event )    -- Increment "currentScore" by 25    text.text = composer.getVariable( "currentScore" ) + 25;    composer.setVariable( "currentScore", composer.getVariable( "currentScore" ) + 25 )    -- Submit new "currentScore" to Game Center leaderboard with ID of "1" in iTunes Connect    gc.request( "setHighScore",        {            localPlayerScore = { category="winners", value=composer.getVariable( "currentScore" ) },            listener = setHighScoreListener        }    ) end local leaderboardId = "winners"; gc.init("gamecenter"); local square = widget.newButton{ defaultFile = "square\_1.png", overFile = "square\_1-over.png", width = 64, height = 64, onRelease = handleButton } square.x, square.y = \_W\*0.5, \_H\*0.5; localGroup:insert(square); local leaderboard = widget.newButton{ defaultFile = "leaderboard.png", overFile = "leaderboard-over.png", width = 92, height = 46, onRelease = showLeaderboards } leaderboard.x, leaderboard.y = \_W\*0.5, \_H\*0.5 + leaderboard.height\*1.5; localGroup:insert(leaderboard); text.x, text.y = \_W\*0.5, square.y - text.height\*5; return localGroup; end

I submitted 50 as my first score. Afterwards, I scored 225, submitted it and the new score shown at the leaderboard was 25. Now, any other score I submit does not replace that last one. What an awkward issue!

Is there anything wrong with my code yet?