Game Center: Leaderboard turns up empty

I’m following the sample code to set up a Game Center leaderboard in my universal iOS game (Corona build 772), but the Leaderboard shows up empty – I see my icon and leaderboard title as I entered it in iTunes Connect for my app, but there’s no scores yet for Today/ Week/ AllTime (shows “No Scores”), even when I saved a score and also got the “Highscore Reported!” callback, and even waited several minutes. The game is not published yet, I’m still testing it (on the actual device, I’m using the iPad 3) using my developer profile.

When loading Game Center, the Apple message shows “Game Center ***Sandbox***”.

Q: Do scores not show up in the sandbox or am I doing something wrong?

A bunch of source code I’m using (not in order/ complete):

[code]
app.leaderboardId = ‘com.versuspad.mygamename.leaderboard’

– …

gameNetwork.init(‘gamecenter’, appCloudHighscoreCallback)

– …

function appSaveData()
if app.score > app.highestAllTimeScore or true then
app.highestAllTimeScore = app.score
if app.loggedIntoCloudHighscore then
appDebug(‘Saving…’)
local viewersInMillion = app.highestAllTimeScore * app.scoreToViewersFactor
gameNetwork.request( ‘setHighScore’, {
localPlayerScore = { category = app.leaderboardId, value = viewersInMillion },
listener = appCloudHighscoreSavedCallback
})
appDebug(‘Saved!’)
end
end
end

function appCloudHighscoreSavedCallback(event)
if event.type == ‘setHighScore’ then
local function alertCompletion()
gameNetwork.request( ‘loadScores’, { leaderboard = { category = app.leaderboardId, playerScope = ‘Global’, timeScope = ‘Week’, range = {1, 25} },
listener = appCloudHighscoreSavedCallback } )
end
native.showAlert( ‘High Score Reported!’, ‘’, { ‘OK’ }, alertCompletion ) – this point is reached

elseif event.type == ‘loadScores’ then
local userBest = misc.getIf(event.localPlayerScore ~= nil, event.localPlayerScore.formattedValue, ‘Not ranked’)
appDebug( 'userBest = ’ … tostring(userBest) )

end
end

function appCloudHighscoreShowLeaderboard()
if app.loggedIntoCloudHighscore then
gameNetwork.show( ‘leaderboards’, { leaderboard = { category = app.leaderboardId, timeScope = ‘Today’ } } )
else
appAlert(‘Please login to Game Center first’, true)
end
end

function appCloudHighscoreCallback(event)
app.loggedIntoCloudHighscore = event.data ~= nil and event.data – this one is true, works fine
end[/code]

Thanks! [import]uid: 10284 topic_id: 23910 reply_id: 323910[/import]

I believe you are doing things correctly. While an app is either running with a Development provisioning profile or an Ad Hoc Provisioning profile, it’s going to run against Apples Sandbox servers for testing.

Once it’s on a distribution profile it will hit the live servers.

To test it, you have to be logged into a specific account for the sandbox, not an account that works for live. Play your game, report your scores. Then you have to logout, create another test account, play that, report the scores, then after some time (could be a few hours), the scores will magically start up. Basically leaderboards won’t show if there are only one player using them.
[import]uid: 19626 topic_id: 23910 reply_id: 96319[/import]

Thanks, good info!

I have a small follow-up question: Should I report scores only when the player reached a new local highscore, or should I report all of them? [import]uid: 10284 topic_id: 23910 reply_id: 96325[/import]

I would report all of them. Game Center has daily, weekly and all time high scores, so lets say a player’s best is 100,000 and that was a month ago, but today they scored 90,000 which could be the best score for today.

Locally I keep the player’s 10 last scores and during my end game processing I add the 11th score to the table, sort the table then remove the last entry. When I show the local scores, I highlight (usually bold) the current score in the top 10. Then I ship the score off to Game Center and let it fall where it may.
[import]uid: 19626 topic_id: 23910 reply_id: 96345[/import]

Ah thanks! Yeah that’s what I should do then too, including the database top scores approach! [import]uid: 10284 topic_id: 23910 reply_id: 96375[/import]