Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

gpgs.getAccountName not responding
Started by pigscanfly2k Mar 18 2020 12:53 PM

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

pigscanfly2k

[GLOBAL: userInfoPane.html]
pigscanfly2k
  • Observer

  • 9 posts
  • Corona SDK

Hi everyone,
 
I have the code below setup to log in to gpgs and I am trying to pull in the account name so I have a unique identifier for the client that is tied to their gpgs account.
 
local loggedintogpgs = 0;
local accountname = "";
 
function gpgsGetAccountNameListener ( event )
infopopup.InfoPopup:create
title="gpgsGetAccountNameListener() callback", 
lines=
{
json.prettify(event)
}:display() 
    if not event.isError then
-- Do account name stuff
accountname = event.accountName;
end
end
 
gpgsLoginListener = function ( event )
    if not event.isError then
if loggedintogpgs==0 then
loggedintogpgs=1
gpgs.getAccountName( gpgsGetAccountNameListener )
end
end
end
 
gpgsInitListener = function ( event )
    if not event.isError then
gpgs.login( { userInitiated=true, listener=gpgsLoginListener } )
end
end
 
gpgs.init( gpgsInitListener )
 
 
Everything above works fine except that the callback to gpgsGetAccountNameListener  never happens and I can't seem to figure out why, and I do believe my permissions are setup with the following:
 
--
-- Android section
--
android =
{
  googlePlayGamesAppId = "XXXXXXXXXX",
  usesPermissions =
  {
    "android.permission.INTERNET",
    "android.permission.GET_ACCOUNTS"
  },
},
 
 
Does anyone have experience using the gpgs.getAccountName function? Or is there some other preferred way to pull in the users account name?
 
Cheers ~


[TOPIC: post.html]
#2

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,415 posts
  • Corona SDK

What version are you using? Please make sure you are using the v2 version here:

 

http://docs.coronalabs.com/plugin/gpgs-v2/index.html



[TOPIC: post.html]
#3

pigscanfly2k

[GLOBAL: userInfoPane.html]
pigscanfly2k
  • Observer

  • 9 posts
  • Corona SDK

Yes, I am using v2, I'm quite certain that is not the issue but thank you.

[TOPIC: post.html]
#4

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,415 posts
  • Corona SDK

Is the playerId and display name enough? I know those work because I use them.

gpgs.players.load(googlePlayServicesListerner) -- loads the current player

and then:

local playerDisplayName = event.players[1].name
local playerId = event.players[1].id


[TOPIC: post.html]
#5

pigscanfly2k

[GLOBAL: userInfoPane.html]
pigscanfly2k
  • Observer

  • 9 posts
  • Corona SDK

 

Is the playerId and display name enough? I know those work because I use them.

gpgs.players.load(googlePlayServicesListerner) -- loads the current player

and then:

local playerDisplayName = event.players[1].name
local playerId = event.players[1].id

 

Thanks for the reply, I am not entirely sure what happened, I didn't change my code at all and all of the sudden it started working just fine, so I guess I should be able to use this as a solution.




[topic_controls]
[/topic_controls]