ok, here is the code - and to clarify, this question is not about the delay. the question is about why everything worked before uploading the apk to the developer console as a beta. I thought there might be some configuration issue, rather than a coding issue (but I have been wrong before… lots). thanks for taking a look!
the function to submit the score and the listener:
-- EXTERNAL LEADERBOARD ---- local function submitScoreListener( event ) print("#17 in the submitScoreListener function - player.lua") -- Google Play Games Services score submission if ( myGlobalData.gpgs ) then -- if not event.isError then --local isBest = nil if ( event.scores["all time"].isNewBest ) then myGlobalData.isleaderboardworthy = "alltime" print("#18 in player submitScoreListener ALLTIME myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) elseif ( event.scores["weekly"].isNewBest ) then myGlobalData.isleaderboardworthy = "weekly" print("#18 in player submitScoreListener WEEKLY myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) elseif ( event.scores["daily"].isNewBest ) then myGlobalData.isleaderboardworthy = "daily" print("#18 in player submitScoreListener DAILY myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) else myGlobalData.isleaderboardworthy = "no high score" print("#18 in player submitScoreListener NO HIGH SCORE myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) end -- Apple Game Center score submission elseif ( myGlobalData.gameCenter ) then if ( event.type == "setHighScore" ) then -- Congratulate player on a high score myGlobalData.isleaderboardworthy = "applehigh" native.showAlert( "Congratulations", "You set a high score!", { "OK" } ) else -- Encourage the player to do better native.showAlert( "Sorry...", "No high score, Better luck next time!", { "OK" } ) end end end local function submitScore( score, mode) print("#4 in the submitScore function") -- manually setting the leaderboard value to trigger response in simulator myGlobalData.isleaderboardworthy = "test value" print("#5 in player submitScore 1 SUBMITSCORE manually set myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) print("#6 in player submitScore 2 last time before the myGlobalData.isleaderboardworthy should set by submitScoreListener") if ( myGlobalData.gpgs ) then -- Submit a score to Google Play Games Services if mode == "reg" then print("#7 in player submitScore 3 - fishing mode - just before submit") myGlobalData.gpgs.leaderboards.submit( { leaderboardId = "myleaderboardID", score = score, listener = submitScoreListener }) elseif mode == "plow" then print("#7 in player submitScore 3 - plow mode - just before submit") myGlobalData.gpgs.leaderboards.submit( { leaderboardId = "myleaderboardID", score = score, listener = submitScoreListener }) end elseif ( myGlobalData.gameCenter ) then -- Submit a score to Apple Game Center if mode == "reg" then myGlobalData.gameCenter.request( "setHighScore", { localPlayerScore = { category = "com.yourdomain.yourgame.leaderboard", value = score }, listener = submitScoreListener }) elseif mode == "plow" then myGlobalData.gameCenter.request( "setHighScore", { localPlayerScore = { category = "com.yourdomain.yourgame.leaderboard", value = score }, listener = submitScoreListener }) end end end
the button to show the leaderboards
----Leaderboard buttons local LB\_Button\_fishing = widget.newButton({ defaultFile = 'images/buttons/leaderboard.png', overFile = 'images/buttons/leaderboard-over.png', width = 45, height = 49, x = halfW + 148, y = 280, x = halfW + 148, y = 280, onRelease = function() print("in the Fishing leaderboard button function") if (myGlobalData.gpgs) then myGlobalData.gpgs.leaderboards.show( "myleaderboardID" ) elseif (myGlobalData.gameCenter) then myGlobalData.gameCenter.show( "leaderboards", { leaderboard = { category = "com.yourdomain.yourgame.leaderboard" } }) end end })
from main.lua
myGlobalData.gpgs = nil myGlobalData.gameCenter = nil ------- new local platform = system.getInfo( "platform" ) local env = system.getInfo( "environment" ) local appstore = system.getInfo("targetAppStore") print("Appstore = "..appstore) if (appstore =="google" and env ~= "simulator" ) then myGlobalData.gpgs = require( "plugin.gpgs" ) elseif ( platform == "ios" and env ~= "simulator" ) then myGlobalData.gameCenter = require( "gameNetwork" ) end -- Google Play Games Services initialization/login listener local function gpgsInitListener( event ) if not event.isError then if ( event.name == "init" ) then -- Initialization event -- Attempt to log in the user --native.showAlert( "Init ", "Successful Initiation!", { "OK" } ) myGlobalData.gpgs.login( { userInitiated=true, listener=gpgsInitListener } ) elseif ( event.name == "login" ) then -- Successful login event print( json.prettify(event) ) end end end -- Apple Game Center initialization/login listener local function gcInitListener( event ) if event.data then -- Successful login event print( json.prettify(event) ) end end -- Initialize game network based on platform if ( myGlobalData.gpgs ) then -- Initialize Google Play Games Services print("trying to init gpgs") myGlobalData.gpgs.init( gpgsInitListener ) elseif ( myGlobalData.gameCenter ) then -- Initialize Apple Game Center myGlobalData.gameCenter.init( "gamecenter", gcInitListener ) end
the calls to the show the leader board if there is a highscore
if params.board == "daily" then print("#17 in the popup:show() with 1 params.board = daily condition") LB\_text:setText ("Today's\nGoogle Play\nhigh score!") LB\_text:setFillColor( 1,1,0) if myGlobalData.plowModeOn =="true" then -- the following should be the onRelease function for the button -- create the button above, set the text, make them visible here, then set the button.onRelease = timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="daily" }); end) else timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="daily" }); end) --myGlobalData.gpgs.leaderboards.show( {leaderboardId="CgkIosnt-ckUEAIQAQ", timeSpan="daily" }) end elseif params.board == "weekly" then print("#17 in the popup:show() with 2 params.board = weekly condition") LB\_text:setText("Google Play\nhigh score of the\nweek!") LB\_text:setFillColor( 1,1,0 ) if myGlobalData.plowModeOn =="true" then timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="weekly"}); end) else timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="weekly"}); end) end elseif params.board == "alltime" then print("#17 in the popup:show() with 3 params.board = alltime condition") LB\_text:setText("Google Play\nALL-TIME\nHigh Score!!") LB\_text:setFillColor( 1,1,0 ) if myGlobalData.plowModeOn =="true" then timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="all time"}); end) else timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="all time"}); end) end elseif params.board == "applehigh" then print("#17 in the popup:show() with 4 params.board = applehigh condition") LB\_text:setText("You made the leaderboard!") LB\_text:setFillColor( 1,1,0 ) if myGlobalData.plowModeOn =="true" then timer.performWithDelay(2500, function() myGlobalData.gameCenter.show( "leaderboards", { leaderboard = { category = "com.yourdomain.yourgame.leaderboard" } }) ;end) else timer.performWithDelay(2500, function() myGlobalData.gameCenter.show( "leaderboards", { leaderboard = { category = "com.yourdomain.yourgame.leaderboard" } }) ;end) end end