Question

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-post from corona forum

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top