Not connected GPGS v2

Yes, same for me, now i have 2 leatherboards… and also, good to know that android studio and unity apps are working fine, maybe it’s time to try unity and leave corona apart for a while till this issue is solved.

@bgmadclown, thank you for the info about GPGS v1 and ARN and crashes.

Rob, I think that you won’t be able to make it work as long as you use a NEW game services play, if you do, it would be great, but it is not only about leaderboards but also about realtime multiplayer, at least in my case.

I’m really hoping that you find out why we are getting “not connected” from gpgs

Hello.

Im having the same issues with gpgs version 2.

How do we manually activate Drive API and Google Play Developer API?

Here is the test code I used with the developer of the GPGS v2 plugin to test snapshots. It’s geared to the way I do things with a faux global table and my internals, so you can’t just copy/paste this code. You will need to modify it to your use:

local myTable = { play = 1 } local snapshotFilename = "snapshot1" local data = json.encode( myTable ) local function gpgsSnapshotOpenForReadListener( event ) print( "snapshot open event:", json.prettify(event) ) if not event.isError then local data = event.snapshot.contents.read() native.showAlert('Snapshots', 'Reading was ' .. (event.isError and 'unsuccessful' or 'successful') .. ',', { 'OK'}) end end local function gpgsSnapshotAfterSaveListener( event ) native.showAlert('Snapshots', 'Saving was ' .. (event.isError and 'unsuccessful' or 'successful') .. '.', {'OK'}) end function myData.openSnapshot() print("Opening snapshot") myData.gpgs.snapshots.open({ filename = snapshotFilename, listener = gpgsSnapshotOpenForReadListener }) end local function gpgsSnapshotOpenForSaveListener( event ) print("open for save listener", json.prettify( event )) if not event.isError then event.snapshot.contents.write(data) -- Write new data as a JSON string into the snapshot myData.gpgs.snapshots.save({ snapshot = event.snapshot, description = 'Save slot ' .. snapshotFilename, listener = gpgsSnapshotAfterSaveListener }) end end function myData.saveSnapshot() print("saving snapshhot") myData.gpgs.snapshots.open({ -- Open the save slot filename = snapshotFilename, create = true, -- Create the snapshot if it's not found listener = gpgsSnapshotOpenForSaveListener }) end

if myData.gpgs then

print(“Initializing GPGS”)

–myData.gpgs.init( gpgsInitListener )

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

end

It looks like I’ve deleted the code to actually call these functions, but it should be pretty obvious how to use them.

Hello Rob!

My main problem is that I can’t even connect using gpgs v2.

My apps are working fine with version 1 for years.

APIs have green marks as you said and everything works fine with version 1.

Also my code is exactly the same as yours.

Some help please!

edit:

Should I update the OAuth 2.0 protocol manually?

On March 7 gpgs version 1 will stop working because of Google+ APIs shutting down.

There is an issue with gpgs version 2 reported months ago from many developers (myself included).

No popup login and snapshots for saving / loading not working.

You are going to leave us without key features in our existing apps.

It was reported that Unity and Android Studio apps has no problem with this change.

It is just Corona.

Rob is alone here. Shouldn’t more Corona stuff post something and try to help us?

Edit:

I’m not using App Signing from Google Play.

What kind of updates should be done (for apps already live in store long ago) in:

play.google.com/apps/publish

and

console.developers.google.com/

??

I have working login and snapshots although login popup doesn’t appear.

Maybe that’s the way it works now for already installed apps?

Posts about APIs and Rob’s code were very helpful and the final touch for me was this:

local data = gpgs.snapshots.getSnapshot (event.snapshotId) -- instead of -- local data = event.snapshot.contents.read()

Thank you :slight_smile:

I don’t believe you will get a login prompt once you have successfully logged in.

Rob

Hi Rob and thank you again for your help.

I didn’t express it correctly.

I was talking about the little popup with the nick name.

With gpgs v.1 it appeared almost every time I was opening an app. 

@Aarbron 

Thank you for showing this: 

local data = gpgs.snapshots.getSnapshot (event.snapshotId)

For the login part, did you try logging out and then completely closing the app from background in the logged out state. And then relaunching the app to login again. Did you get any errors or the login functionality still works for you? 

I am using isAuthenticated() to check but I get runtime error if i follow the above steps. 

@mysticeti

Didn’t try that.

I use gpgs only for snapshots. 

@aarbron

I understand that but what I am trying to say is that when you implement login button for user to login to use snapshots do you use isAuthenticated() to check whether user is already logged in to show that the user is logged in already? I am using the using the following code to implement the login button for gpgs. I always get runtime error if the user is in logged out state and trying to log back in. This error doesn’t happen at the very first run of the game, everything from login, snapshots and other functionality seems to work fine. This happens only when a user might log out from gpgs and closes the app from the background and tries to log back in later.  

local function googVerify () if ( composer.getSceneName( "current" ) == "scoreboardScreen" and (globalData.gpgs) ) thengpgsButtonDisplayObjects.gpgsLoggedInButton = display.newImageRect(analyticsImageSheet, 10, analyticsSheetInfo.sheet.frames[10].width, analyticsSheetInfo.sheet.frames[10].height)         gpgsButtonDisplayObjects.gpgsLoggedInButton.isVisible = false         gpgsButtonDisplayObjects.gpgsLoggedInButton.x = display.contentWidth \* 0.50         gpgsButtonDisplayObjects.gpgsLoggedInButton.y = display.contentHeight \* 0.29         sceneGroup:insert( gpgsButtonDisplayObjects.gpgsLoggedInButton )         scrollView:insert( gpgsButtonDisplayObjects.gpgsLoggedInButton )         gpgsButtonDisplayObjects.gpgsLoggedInButton:scale(display.contentWidth \* 0.0015, display.contentWidth \* 0.0015)         gpgsButtonDisplayObjects.gpgsLoggedOutButton = display.newImageRect(analyticsImageSheet, 11, analyticsSheetInfo.sheet.frames[11].width, analyticsSheetInfo.sheet.frames[11].height)         gpgsButtonDisplayObjects.gpgsLoggedOutButton.isVisible = false         gpgsButtonDisplayObjects.gpgsLoggedOutButton.x = display.contentWidth \* 0.50         gpgsButtonDisplayObjects.gpgsLoggedOutButton.y = display.contentHeight \* 0.29         sceneGroup:insert( gpgsButtonDisplayObjects.gpgsLoggedOutButton )         scrollView:insert( gpgsButtonDisplayObjects.gpgsLoggedOutButton )         gpgsButtonDisplayObjects.gpgsLoggedOutButton:scale(display.contentWidth \* 0.0014, display.contentWidth \* 0.0014)          if ( gameData.gpgsDataFirstCheck == false ) then           if ( (globalData.gpgs) and (globalData.gpgs.isAuthenticated()) ) then              gpgsButtonDisplayObjects.gpgsLoggedInButton.isVisible = true             gpgsDownloadData()           else              gpgsButtonDisplayObjects.gpgsLoggedOutButton.isVisible = true           end          else           gpgsDownloadData()           gameData.gpgsDataFirstCheck = false           globalData.loadsave.saveTable( gameData, "gameData.json" )         end -- first time game opening check to prevent gpgs button overlap         scoreboardFunctions.onGpgsLoginButtonTap = function( self, event )           if ( (globalData.gpgs) and (globalData.gpgs.isAuthenticated()) ) then             --logout             globalData.gpgs.logout()             gameData.gpgsDataUserPref = "logged out"             globalData.loadsave.saveTable( gameData, "gameData.json" )             gpgsButtonDisplayObjects.gpgsLoggedOutButton.isVisible = true             gpgsButtonDisplayObjects.gpgsLoggedInButton.isVisible = false           elseif (globalData.gpgs) then             --login             globalData.gpgs.login( { userInitiated = true, listener = gpgsLoginListener } )             local function toggleGPGSToLogin ()               if ((globalData.gpgs) and (globalData.gpgs.isAuthenticated()) ) then                 gpgsButtonDisplayObjects.gpgsLoggedOutButton.isVisible = false                 gpgsButtonDisplayObjects.gpgsLoggedInButton.isVisible = true               end             end             timerToggleGPGSCheck = timer.performWithDelay(500, toggleGPGSToLogin, 3)           end -- login or logout conditional END           return true         end -- onGpgsLoginButtonTap func END         gpgsButtonDisplayObjects.gpgsLoggedInButton:addEventListener( "tap", scoreboardFunctions.onGpgsLoginButtonTap )         gpgsButtonDisplayObjects.gpgsLoggedOutButton:addEventListener( "tap", scoreboardFunctions.onGpgsLoginButtonTap )       end -- googLicensed END     end -- googVerify func END

Would appreciate the help very much. 

@mysticeti

Sorry I don’t use isAuthenticated()!!

gpgs v2 is beta, I guess Corona will improve it.

I’m also having the same problem but some people say their problems are solved when they manually activate the following APIs: Drive API and Google Play Developer API.

If you enabled those, you are probably having the same issue as me. No errors thrown, event.phase is “logged in” but the player is neither connected nor authenticated.

As a test, I would remove the check for event.isError to see if you can connect.

I tend to use isConnected() when I attempt a GPGS call.

Same here.

The weird thing is I’m sharing a big part of the code in 4 different games.

The one game connects and shows leaderboard as it should, the other three won’t. With the same code.

I’m not using the isConnected parameter but it shouldn’t be a problem since my first game actually connects.

Using release keystore.

I’ve enabled all the necessary APIs.

Double and triple checked my authentication parameters.

Tried with latest public build and two fifferent daily builds.

I can see on adb logcat the “logged in” event but when I call leaderboards.show I get “plugin.gpgs. not connected”.

One thing I find weird is that in the first game that leaderboards do work, abd logcat gives me two “logged in” events in a row.

But the other three games that leaderboards don’t work, I only get one “logeed in” event.

Well, I’ve been trying to get this to work for 2 days now with no success. Has anyone else resolved this?  :wacko:

Still struggling, looking at the requests received by the drive api they all result in errors.

I wish I had an answer for you. This is working as expected in my game. I wish Google didn’t make setting things up so difficult. I’m going to post the settings for my game along with some notes:

First my build.settings “android” section:

 android = { googlePlayGamesAppId = "249XXXXXXX34", -- this has to match what is online facebookAppId = "16XXXXXXXXXXXX61", usesPermissions = { "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", "android.permission.INTERNET", "android.permission.VIBRATE", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_NETWORK\_STATE", -- needed for the vungle plugin }, supportsScreens = { resizeableActivity = false, smallScreens = true, normalScreens = true, largeScreens = true, xlargeScreens = true, }, },

Go to the Game Services tab and find your game there:

Click on your game to get the value for googlePlayGamesAppId. Even though it looks like a number, make it a string!

Scroll to the bottom and make sure you have green checkmarks here:

Check on the linked app section and make sure your real game is linked. Both are likely sharing similar names.

Make sure you have a leaderboard added and published.

Finally, make sure you have no “triangle” “todo” logos here:

Then follow the tutorial on adding leaderboards to your app. My code will be a little different than the tutorial (but the tutorial was based on this and made more generic).

myData.gpgs = nil print("platform: ", myData.platform, system.getInfo("environment")) if "android" == myData.platform and "simulator" ~= system.getInfo("environment") then print("requiring GPGS") myData.gpgs = require("plugin.gpgs.v2") end local function gpgsLoginListener( event ) print("\*\*\* gpgsLoginListener \*\*\*") print( json.prettify( event ) ) if not event.isError then if ( event.name == "login" ) then -- Successful login event myData.isGameNetworkingLoggedIn = true print("I think isConnected() is", myData.gpgs.isConnected()) end end end if myData.gpgs then print("Initializing GPGS") --myData.gpgs.init( gpgsInitListener ) myData.gpgs.login( { userInitiated=true, listener=gpgsLoginListener } ) end

For testing purposes, I added a button to my UI to set a high score. It’s hard to test this through normal game play because getting a new high score is tough.

 local function gcSubmitScoreListener() print("submitted") end local gpgsSetHighScoreButton = widget.newButton({ label = "Set High Score", onRelease = function( event ) myData.settings.highScore = myData.settings.highScore + 100000 myData.gpgs.leaderboards.submit({ leaderboardId = "CgkXXXXXXXXXXXXQBg", score = myData.settings.highScore, listener = gcSubmitScoreListener } ) end, }) sceneGroup:insert(gpgsSetHighScoreButton) gpgsSetHighScoreButton.x = display.contentWidth - 50 gpgsSetHighScoreButton.y = display.contentHeight - 20

Then to show the score:
 

local function gameNetworkingLeaderboards() print("\*\*\* gameNetworking leaderboards \*\*\*") if myData.gameNetwork then print("\*\*\* gameNetwork: attempting to call show leaderboard") myData.gameNetwork.show( "leaderboards", { leaderboard = { category = "com.myawesomegame.leaderboard" }, listener = showLeaders }) elseif myData.gameCenter then print("\*\*\* gameCenter leaderboards") myData.gameCenter.leaderboards.show("com.myawesomegame.leaderboard") elseif myData.gpgs then print("\*\*\* GPGS trying to show GPGS leaderboard", myData.gpgs.isConnected()) myData.gpgs.leaderboards.show( ) end end

This works for me. Did I get everything above? Who knows. Google keeps changing things and making it hard to find all the settings.

Can you copy/paste this code? Not a chance because you’re likely not using the same faux globals table I’m using. My ID’s have been masked. You likely have named functions differently.

But this works.

Thanks for the answer! I’ll go through my game again to make sure it’s all setup correctly and hopefully I’ll be able to solve it.

What’s odd though is that the code I’m using now works for another game that I published a while back. Was the application above built recently? I’m curious to see if it works if you build a new application now, if it’s not too much trouble of course. If it still works after that then it should be something wrong on my end.  :wacko: