Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

GPGS connects, but doesn’t login
Started by philipp3 Nov 08 2018 09:01 AM

11 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

philipp3

[GLOBAL: userInfoPane.html]
philipp3
  • Enthusiast

  • 70 posts
  • Corona SDK

Hello,

 

As I want to update to GPGS V2, I need to check its functionality.

 

The following was already the case with GPGS V1:

When I want to test the game, the dialogue "Connecting To..." pops up, turns to a green Google Play box, a loading circle appears and disappears abruptly. I think it wants to log in my user, but cancels for some reason. When I call gpgs.leaderboards.show("") then, nothing happens.

When I download the same game from the Play Store, it logs in fine: The dialogue that comes from the top and says "Welcome back, xyz-user" shows, and the leaderboard is able to open.

 

The loginCallbackGpgs() gets called, the loadLocalPlayerCallback() doesn’t get called.

 

This is the code that I use (V2):

local function loadLocalPlayerCallback(e)
    --- this does not get called
end

local function loginCallbackGpgs(e)
    --- this gets called successfully
    gpgs.players.load({listener = loadLocalPlayerCallback})
end

gpgs.login({userInitiated = true, listener = loginCallbackGpgs})


--- then some time later:

function showLeaderboards()
    gpgs.leaderboards.show("xyz")
end


[TOPIC: post.html]
#2

steinovehelset

[GLOBAL: userInfoPane.html]
steinovehelset
  • Enthusiast

  • 33 posts
  • Corona SDK

@philipp3

Can you add this line to the "loginCallbackGpgs" function?
print( json.prettify(event) )

 

This way you can see if you have actually been authenticated. "loginCallbackGpgs" will be called even if there is an error. So you need to check inside this function if you're connected or what.



[TOPIC: post.html]
#3

philipp3

[GLOBAL: userInfoPane.html]
philipp3
  • Enthusiast

  • 70 posts
  • Corona SDK

@philipp3

Can you add this line to the "loginCallbackGpgs" function?
print( json.prettify(event) )

 

This way you can see if you have actually been authenticated. "loginCallbackGpgs" will be called even if there is an error. So you need to check inside this function if you're connected or what.

 

This is the code:

gpgs = require( "plugin.gpgs.v2" )

function uploadHighScore()
    print ("_uploadHighScore", finishedSoManyLevels)
    if gpgs.isConnected() then
        gpgs.leaderboards.submit({leaderboardId = "xyz", score = finishedSoManyLevels})
    end
end

function loadLocalPlayerCallback(e)
    print ("gpgs load player")
end


function loginCallbackGpgs(event)
    print ("gpgs login")
    print(json.prettify(event))
    uploadHighScore()
    gpgs.players.load({listener = loadLocalPlayerCallback})
end

gpgs.login({userInitiated = true, listener = loginCallbackGpgs})

This is the log (I don’t know why login is called twice):

 

11-15 11:40:51.643 14463 14478 I Corona  : gpgs login

11-15 11:40:51.643 14463 14478 I Corona  : {

11-15 11:40:51.643 14463 14478 I Corona  :   "name":"login",

11-15 11:40:51.643 14463 14478 I Corona  :   "phase":"logged in",

11-15 11:40:51.643 14463 14478 I Corona  :   "isError":false

11-15 11:40:51.643 14463 14478 I Corona  : }

11-15 11:40:51.643 14463 14478 I Corona  : _uploadHighScore 10

11-15 11:40:51.649 14463 14478 W plugin.gpgs.v2: Not connected

11-15 11:40:51.653 14463 14478 W plugin.gpgs.v2: Not connected

11-15 11:40:51.653 14463 14478 I Corona  : gpgs login

11-15 11:40:51.653 14463 14478 I Corona  : {

11-15 11:40:51.653 14463 14478 I Corona  :   "name":"login",

11-15 11:40:51.653 14463 14478 I Corona  :   "phase":"logged in",

11-15 11:40:51.653 14463 14478 I Corona  :   "isError":false

11-15 11:40:51.653 14463 14478 I Corona  : }

11-15 11:40:51.653 14463 14478 I Corona  : _uploadHighScore 10

11-15 11:40:51.656  1331  7006 I ActivityManager: START u0 {act=com.google.android.gms.auth.GOOGLE_SIGN_IN pkg=com.google.android.gms cmp=com.google.android.gms/.auth.api.signin.ui.SignInActivity (has extras)} from uid 10152 on display 0

11-15 11:40:51.664 14463 14478 W plugin.gpgs.v2: Not connected

11-15 11:40:51.667 14463 14478 W plugin.gpgs.v2: Not connected



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,147 posts
  • Corona SDK

Can you show your code where you're calling login?

 

Rob



[TOPIC: post.html]
#5

philipp3

[GLOBAL: userInfoPane.html]
philipp3
  • Enthusiast

  • 70 posts
  • Corona SDK

Can you show your code where you're calling login?

 

Rob

 

I updated the code above.



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,147 posts
  • Corona SDK

I was hoping for more details like you have it inside a scene:show() function or inside a button handler. I can't tell the context you're calling the login function above?

 

Rob



[TOPIC: post.html]
#7

philipp3

[GLOBAL: userInfoPane.html]
philipp3
  • Enthusiast

  • 70 posts
  • Corona SDK

I was hoping for more details like you have it inside a scene:show() function or inside a button handler. I can't tell the context you're calling the login function above?

 

Rob

 

I don’t use scenes or anything, this is the code how it appears in main.lua. It’s not inside a function and has no delay.



[TOPIC: post.html]
#8

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,147 posts
  • Corona SDK

Can you build a simple demo app that has this issue that I can just drop my Google App Id into, change the leaderboard id and test and share that simple test project with us?

 

Thanks

Rob



[TOPIC: post.html]
#9

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,147 posts
  • Corona SDK

I took the code above, added some additional logging and a call to show the leaderboard after saving the value. I applied it to a game I'm building and everything worked as expected. The score updated. the call to show the scores worked.

 

Rob



[TOPIC: post.html]
#10

philipp3

[GLOBAL: userInfoPane.html]
philipp3
  • Enthusiast

  • 70 posts
  • Corona SDK

I was trying to make a small isolated demo project, but still no luck for me. I am getting "plugin.gpgs.v2: Not connected" every time.

 

Could this also be an issue of build.settings, or the Google login?



[TOPIC: post.html]
#11

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,147 posts
  • Corona SDK

This sounds like something local to your setup... There are several steps that are easy to miss in the Google Play console.

 

Rob



[TOPIC: post.html]
#12

philipp3

[GLOBAL: userInfoPane.html]
philipp3
  • Enthusiast

  • 70 posts
  • Corona SDK

I see, I will take a look at the console again.




[topic_controls]
[/topic_controls]