GPGS auto login?

Is there an example on how to implement the auto login for GPGS correctly at app start and when the user is clicking a button to access GPGS somewhere?

Same for GameCenter?

I somehow have the problem the GPGS is not active at first start of the app… only when I go outside of the app and returning the GPGS sometimes can be accessed and a leaderboard can be shown.

Happy New Year to everyone! :slight_smile:

I would suggest going through this tutorial:

https://docs.coronalabs.com/tutorial/games/gameLeaderboards/index.html

Rob

Thank you for the info Rob!

I have the same problem because I always get into the error state it seems. With this:

gpgsInitListener = function ( event ) if not event.isError then if ( event.name == "init" ) then -- Initialization event -- Attempt to log in the user globalData.gpgs.login( { userInitiated=true, listener=gpgsInitListener } ) \_G.FirstTime = 1 elseif ( event.name == "login" ) then -- Successful login event --print( json.prettify(event) ) if \_G.loggedintogpgs==0 then \_G.loggedintogpgs=1 end end else performWithDelay (6000,function() globalData.gpgs.init( gpgsInitListener ) end,1) end end globalData.gpgs.init( gpgsInitListener )

The app always tries to init after 6 seconds… is there a way to get more info on the error which is causing this?

I got a little bit more info:

errorCode: 10002

errorMessage: sign in failed

isError: true

name: login

phase: logged in

So according to Google, as you noted is it’s a “sign in” failed message:  https://developers.google.com/android/reference/com/google/android/gms/games/GamesActivityResultCodes

The attempt to sign in to the Games service failed. For example, this might happen if the network is flaky, or the user’s account has been disabled, or consent could not be obtained.

This guy seems to have a solution. I’m not sure how realistic it is, but it was one of the top hits in a Google search.  https://geekhole.uk/android/2016/01/15/google-play-game-services-error-10002-result-sign-in-failed/

This message seems to echo the one above:

https://stackoverflow.com/questions/30721883/error-connecting-to-google-play-games

It might be worth a deeper dive into a google search for “Google Play Games Service error 10002” and see if there are more results (I just picked off the 1st page).

Rob

I would suggest going through this tutorial:

https://docs.coronalabs.com/tutorial/games/gameLeaderboards/index.html

Rob

Thank you for the info Rob!

I have the same problem because I always get into the error state it seems. With this:

gpgsInitListener = function ( event ) if not event.isError then if ( event.name == "init" ) then -- Initialization event -- Attempt to log in the user globalData.gpgs.login( { userInitiated=true, listener=gpgsInitListener } ) \_G.FirstTime = 1 elseif ( event.name == "login" ) then -- Successful login event --print( json.prettify(event) ) if \_G.loggedintogpgs==0 then \_G.loggedintogpgs=1 end end else performWithDelay (6000,function() globalData.gpgs.init( gpgsInitListener ) end,1) end end globalData.gpgs.init( gpgsInitListener )

The app always tries to init after 6 seconds… is there a way to get more info on the error which is causing this?

I got a little bit more info:

errorCode: 10002

errorMessage: sign in failed

isError: true

name: login

phase: logged in

So according to Google, as you noted is it’s a “sign in” failed message:  https://developers.google.com/android/reference/com/google/android/gms/games/GamesActivityResultCodes

The attempt to sign in to the Games service failed. For example, this might happen if the network is flaky, or the user’s account has been disabled, or consent could not be obtained.

This guy seems to have a solution. I’m not sure how realistic it is, but it was one of the top hits in a Google search.  https://geekhole.uk/android/2016/01/15/google-play-game-services-error-10002-result-sign-in-failed/

This message seems to echo the one above:

https://stackoverflow.com/questions/30721883/error-connecting-to-google-play-games

It might be worth a deeper dive into a google search for “Google Play Games Service error 10002” and see if there are more results (I just picked off the 1st page).

Rob