help with google play services

Hello …

I’m having trouble with google play services. I can not understand his logic in Corona API documentation. The only command that seems to work is the game Network.request (“login”) which logs the local player. The rest, no matter what I do, nothing works.

local function requestCallback(isError)

    if (isError) then

        print(“login failed”)

    else

        print(“login success”)

    end

end

print(“Calling login”)

gameNetwork.request( “login”,

{

    userInitiated = true,

    listener = requestCallback

})

For example: My game is made score, where the player has to get the highest score possible. During the game, in certain score, there is a speech and I joined together a 'unlockAchievement ". But as I said, nothing works.

local function conquista ( myAchievement ) 

gameNetwork.request( “unlockAchievement”,

{

    achievement =

    {

    identifier = myAchievement

    }

}

)

end

if (primeiraconquista == false) then

     conquista(abrirconquista)

     abrirconquista = “CgkIiP_n0sobEAIQCQ”

     primeiraconquista = true

end

if score > 99 and contadoraudio[0] ~= true then

     audio.play(apontos[0])

     contadoraudio[0] = true

     abrirconquista = “CgkIiP_n0sobEAIQAg”

     conquista(abrirconquista)

elseif score > 499 and contadoraudio[1] ~= true then

     audio.play(apontos[1])

     contadoraudio[1] = true

     abrirconquista = “CgkIiP_n0sobEAIQAw”

     conquista(abrirconquista)

elseif score > 999 and contadoraudio[2] ~= true then

     audio.play(apontos[2])

     contadoraudio[2] = true

     abrirconquista = “CgkIiP_n0sobEAIQBA”

     conquista(abrirconquista)

elseif score > 1499 and contadoraudio[3] ~= true then

     audio.play(apontos[3])

     contadoraudio[3] = true

     abrirconquista = “CgkIiP_n0sobEAIQBQ”

     conquista(abrirconquista)

elseif score > 1999 and contadoraudio[4] ~= true then

     audio.play(apontos[4])

     contadoraudio[4] = true

     abrirconquista = “CgkIiP_n0sobEAIQBg”

     conquista(abrirconquista)

elseif score > 2499 and contadoraudio[5] ~= true then

     audio.play(apontos[5])

     contadoraudio[5] = true

     abrirconquista = “CgkIiP_n0sobEAIQBw”

     conquista(abrirconquista)

elseif score > 2999 and contadoraudio[6] ~= true then

     audio.play(apontos[6])

     contadoraudio[6] = true

     abrirconquista = “CgkIiP_n0sobEAIQCA”

     conquista(abrirconquista)

end

this is just one example. I can not save the score in my Leaderboard too. Nothing works, I do not understand the logic of it.

If any good with patience soul can help me, I thank you very much.

I am not seeing all your code so forgive me if this is all there. I just tested this on my app and it works fine for me.

  1. Check monitor and see if you see any errors.

  2. Make sure you publish your leaderboards or use the test account.

What follows is the exact bits of code that work on my app except for the actual Ids.

  1. Add your id to the build settings:

    android = { usesPermissions = { “android.permission.INTERNET”, }, googlePlayGamesAppId = “yourAppId”, },

  2. Add the plugin to the settings file:

    [“CoronaProvider.gameNetwork.google”] = { publisherId = “com.coronalabs”, supportedPlatforms = { android=true } },

  3. Init the gameNetwork and login if successful (from one of the lua files):

    local function initCallback( event ) if not event.isError then gameNetwork.request( “login”, { userInitiated = true, listener = requestLogIn } ) else print( “Error Code:”, event.errorCode ); end end gameNetwork.init( “google”, initCallback );

  4. Call the function. You can check for errors in the listener method:

    if finalScore > 9 then gameNetwork.request( “unlockAchievement”, { achievement = { identifier = “yourAchievementId” }, listener = requestCallback } ) end gameNetwork.request( “setHighScore”, { localPlayerScore = { category=“categoryId”, value=<topscore> }, listener = requestCallback } )

I am not seeing all your code so forgive me if this is all there. I just tested this on my app and it works fine for me.

  1. Check monitor and see if you see any errors.

  2. Make sure you publish your leaderboards or use the test account.

What follows is the exact bits of code that work on my app except for the actual Ids.

  1. Add your id to the build settings:

    android = { usesPermissions = { “android.permission.INTERNET”, }, googlePlayGamesAppId = “yourAppId”, },

  2. Add the plugin to the settings file:

    [“CoronaProvider.gameNetwork.google”] = { publisherId = “com.coronalabs”, supportedPlatforms = { android=true } },

  3. Init the gameNetwork and login if successful (from one of the lua files):

    local function initCallback( event ) if not event.isError then gameNetwork.request( “login”, { userInitiated = true, listener = requestLogIn } ) else print( “Error Code:”, event.errorCode ); end end gameNetwork.init( “google”, initCallback );

  4. Call the function. You can check for errors in the listener method:

    if finalScore > 9 then gameNetwork.request( “unlockAchievement”, { achievement = { identifier = “yourAchievementId” }, listener = requestCallback } ) end gameNetwork.request( “setHighScore”, { localPlayerScore = { category=“categoryId”, value=<topscore> }, listener = requestCallback } )