This has been driving me nuts for days now.
In a previous app I did GC and after some struggle it worked fine.
So it should have been a breeze with the app in development now. No such luck.
I set up a Development provisioning profile with the correct AppID.
I created the app in iTunes Connect, added a leaderboard.
I created several test users in iTC.
Logged out of the GC before starting the app either on my device or the Xcode simulator.
This is the build.settings file:
settings = {
iphone = {
plist = {
components = {}
}
},
}
So far so good.
Logging on to the GC is no problem. It reports the user name and remarks “Sandbox”.
Doing a gameNetwork.show(…) works fine too. I see the 2 leaderboards (empty ofc).
Now when I post a score (see sample code) it even reports back that I’ve submitted a score (10 in this case) on a category (“survival” in this case), but neither loadScores nor showing the leaderboard shows any scores! Even after waiting for 24 hrs (or more).
The loadScores return an event.data that is a null value.
I know I’m missing something, but what?!
Any ideas?
Thanks!!
[code]
local gameNetwork = require “gameNetwork”
local json = require “json”
io.output():setvbuf(“no”)
local loggedIntoGC = false
local function requestCallback( event )
if not (event.type == nil) then
local data = json.encode( event.data )
native.showAlert( “event.data”, data, { “OK” } )
end
if event.type == “loadLocalPlayer” then
currentPlayerName = event.data.alias
native.showAlert( “player name”, currentPlayerName, { “OK” } )
elseif event.type == “setHighScore” then
local function alertCompletion() gameNetwork.request( “loadScores”, { leaderboard={ category=“survival” }, listener=requestCallback } ); end
native.showAlert( “High Score Reported!”, “”, { “OK” }, alertCompletion )
elseif event.type == “loadScores” then
if event.data then
local topRankID = event.data[1].playerID
local topRankScore = event.data[1].formattedValue
local bestTextValue = string.sub( topRankScore, 1, 12 ) … “…”
print(topRankID … “-” … topRankScore … “-” … bestTextValue)
print(“Fetching players”)
if topRankID then gameNetwork.request( “loadPlayers”, { playerIDs={ topRankID }, listener=requestCallback} ); end
else
print(“No data from loadScores”)
end
native.showAlert( “loadScores”, topRankID, { “OK” } )
elseif event.type == “loadPlayers” then
if event.data then
local topRankAlias = event.data[1].alias
if topRankAlias then
native.showAlert( “Top rank”, topRankAlias, { “OK” } )
end
end
elseif event.type == “leaderboards” then
native.showAlert( “reqCB”, “Showing board”, { “OK” } )
end
return true
end
local function initCallback( event )
if event.data then
loggedIntoGC = true
gameNetwork.request( “loadLocalPlayer”, { listener=requestCallback } )
else
native.showAlert(“Log in GC failed!”, “”, {“OK”})
end
return true
end
local function setHighscore( event )
if event.phase == “ended” then
print(“setting highscore”)
local userScore = 10
if loggedIntoGC then gameNetwork.request( “setHighScore”, { localPlayerScore={ category=“survival”, value=userScore }, listener=requestCallback } ); end
end
end
local function showLeaderboard( event )
if event.phase == “ended” then
print(“showing leaderboard”)
gameNetwork.show( “leaderboards”, { leaderboard = { category=“survival” }, listener=requestCallback })
end
end
local btn = display.newRect(100,100,200,100)
btn:setFillColor(255)
btn:addEventListener(“touch”, setHighscore)
local showGC = display.newRect(100,300,200,100)
showGC:setFillColor(150)
showGC:addEventListener(“touch”, showLeaderboard)
gameNetwork.init( “gamecenter”, initCallback ) --startGC() --Initializes the Game Center
[/code] [import]uid: 123200 topic_id: 26540 reply_id: 326540[/import]