gameNetwork + game center iOs not working

Hi,

I’m getting crazy about this issue. Here is my code:

main.lua

gameNetwork = require “gameNetwork”

loggedIntoGC = false

local function initCallback( event )

    if event.data then

        loggedIntoGC = true

        – native.showAlert( “Success!”, “User has logged into Game Center”, { “OK” } )

    else

        loggedIntoGC = false

        gameNetwork.request( “loadScores”, 

            { leaderboard={ category=“com.mycompany.mygame.myrankingid”, 

            playerScope=“Global”, timeScope=“AllTime”, range={1,50} },

            listener=requestCallback } )

        – native.showAlert( “Fail”, “User is not logged into Game Center”, { “OK” } )

    end

end

– function to listen for system events

local function onSystemEvent( event ) 

    if event.type == “applicationStart” then

        gameNetwork.init( “gamecenter”, initCallback )

        return true

    end

end

Runtime:addEventListener( “system”, onSystemEvent )

Then just to test:

if loggedIntoGC then 

    gameNetwork.request( “setHighScore”, 

      { localPlayerScore={ category=“com.mycompany.mygame.myrankingid”, value=t.text }, 

      listener=requestCallback } ); 

end

if loggedIntoGC then 

    gameNetwork.request( “loadScores”, 

      { leaderboard={ category=“com.mycompany.mygame.myrankingid”, playerScope=“Global”, timeScope=“AllTime”, range={1,50} }, 

      listener=requestCallback } ); 

end

if loggedIntoGC then 

    gameNetwork.show( “leaderboards”, 

      { leaderboard={ category=“com.mycompany.mygame.myrankingid”, timeScope=“AllTime” } } ); 

end

Trying example on device do nothing, just login game center user…

Any help, please?

Finally, now it shows game center leaderboard window, but don’t know why is always in blank. Maybe, is it because of sandbox mode?

main.lua

 

 

gameNetwork = require “gameNetwork”

loggedIntoGC = false

 

 

local function initCallback( event )

    if event.data then

        loggedIntoGC = true

        – native.showAlert( “Success!”, “User has logged into Game Center”, { “OK” } )

    else

        loggedIntoGC = false

        gameNetwork.request( “loadScores”, 

            { leaderboard={ category=“com.mycompany.mygame.myrankingid”, 

            playerScope=“Global”, timeScope=“AllTime”, range={1,50} },

            listener=requestCallback } )

 

        – native.showAlert( “Fail”, “User is not logged into Game Center”, { “OK” } )

    end

end

 

– function to listen for system events

local function onSystemEvent( event ) 

    if event.type == “applicationStart” then

        gameNetwork.init( “gamecenter”, initCallback )

        return true

    end

end

Runtime:addEventListener( “system”, onSystemEvent )

 

 

 

if loggedIntoGC then 

    gameNetwork.request( “setHighScore”, 

      { localPlayerScore={ category=“com.mycompany.mygame.myrankingid”, value=t.text }, 

      listener=requestCallback } ); 

end

 

 

function requestCallback( event )

    if event.type == “setHighScore” then

      if loggedIntoGC then 

        gameNetwork.request( “loadScores”, 

        { leaderboard={ category=“com.mycompany.mygame.myrankingid”, playerScope=“Global”, timeScope=“AllTime”, range={1,99} }, 

        listener=requestCallback } ); 

      end

    elseif event.type == “loadScores” then

      if loggedIntoGC then 

        gameNetwork.show( “leaderboards”, 

        { leaderboard={ category=“com.mycompany.mygame.myrankingid”, timeScope=“AllTime” } } ); 

      end

    end

end

Finally, now it shows game center leaderboard window, but don’t know why is always in blank. Maybe, is it because of sandbox mode?

main.lua

 

 

gameNetwork = require “gameNetwork”

loggedIntoGC = false

 

 

local function initCallback( event )

    if event.data then

        loggedIntoGC = true

        – native.showAlert( “Success!”, “User has logged into Game Center”, { “OK” } )

    else

        loggedIntoGC = false

        gameNetwork.request( “loadScores”, 

            { leaderboard={ category=“com.mycompany.mygame.myrankingid”, 

            playerScope=“Global”, timeScope=“AllTime”, range={1,50} },

            listener=requestCallback } )

 

        – native.showAlert( “Fail”, “User is not logged into Game Center”, { “OK” } )

    end

end

 

– function to listen for system events

local function onSystemEvent( event ) 

    if event.type == “applicationStart” then

        gameNetwork.init( “gamecenter”, initCallback )

        return true

    end

end

Runtime:addEventListener( “system”, onSystemEvent )

 

 

 

if loggedIntoGC then 

    gameNetwork.request( “setHighScore”, 

      { localPlayerScore={ category=“com.mycompany.mygame.myrankingid”, value=t.text }, 

      listener=requestCallback } ); 

end

 

 

function requestCallback( event )

    if event.type == “setHighScore” then

      if loggedIntoGC then 

        gameNetwork.request( “loadScores”, 

        { leaderboard={ category=“com.mycompany.mygame.myrankingid”, playerScope=“Global”, timeScope=“AllTime”, range={1,99} }, 

        listener=requestCallback } ); 

      end

    elseif event.type == “loadScores” then

      if loggedIntoGC then 

        gameNetwork.show( “leaderboards”, 

        { leaderboard={ category=“com.mycompany.mygame.myrankingid”, timeScope=“AllTime” } } ); 

      end

    end

end