Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Google Play Games Services v2 (plugin beta)
Started by genelixis Sep 01 2018 09:03 AM

30 replies to this topic
[TOPIC CONTROLS]
Page 1 of 2 1 2
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

genelixis

[GLOBAL: userInfoPane.html]
genelixis
  • Enthusiast

  • 38 posts
  • Corona SDK

Just checked gpgs version 2 beta.

Replacing "plugin.gpgs" with "plugin.gpgs.v2" where needed.

 

I was checking snapshots functionality in one of my games (live on play store).

 

Google Play Games window appeared only once (although I did data reset or reinstall)

Didn't retrieve info and there are a lot of crashes in device.

 

I will check it again next week and post logs too.

 

Anyone else?

 


[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

Hi @genelixis

 

This isn't all that helpful to us. Can you share what errors your getting and the code you're using that's failing? It's really hard for me to go to the engineers with "It's not working. Fix it" with no specifics.

 

Copies of the errors from the device's console log would be really great.

 

Rob



[TOPIC: post.html]
#3

genelixis

[GLOBAL: userInfoPane.html]
genelixis
  • Enthusiast

  • 38 posts
  • Corona SDK

You are right Rob!

 

As I said, I will test it again and post logs next week.

 

I'm waiting, at least, Google Play Services login window to start appearing :)

 

Also sample link is not working.

That would help everybody, a lot!!



[TOPIC: post.html]
#4

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 520 posts
  • Corona SDK

@rob, I’m about to go live with a new app - should I be using this beta plugin?

[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

The GPGS v2 plugin was in a **closed** test. We had invited a few specific people to work on it. Somehow it was made public. It is not ready to be used in production apps.

 

We were trying to fix a particular issue that Google was flagging with logins during some feature review. Very few people have reported this problem and the GPGS v1 plugin is working just fine for almost everyone. However to address this problem (which we suspect will impact more people in the future) we had to completely re-write the entire plugin. That means we have to exercise every node.

 

The only people who should be using the v2 plugin now are those who are willing to test it and share code and report errors and not have it impact their production.

 

@genelixis I don't know that not seeing a login popup is a bug that prevents you from testing this. It does appear to successfully log you in.  

 

Rob



[TOPIC: post.html]
#6

genelixis

[GLOBAL: userInfoPane.html]
genelixis
  • Enthusiast

  • 38 posts
  • Corona SDK

GPGS v1 plugin is not working if you do a build now.

 

Login popup appears but save / retrieve data using snapshots is not working.

 

Am I wrong?



[TOPIC: post.html]
#7

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

We haven't touched the V1 plugin.

 

EDIT: we did update the plugin on 8/8 to work with Android API level 27.

 

Rob



[TOPIC: post.html]
#8

genelixis

[GLOBAL: userInfoPane.html]
genelixis
  • Enthusiast

  • 38 posts
  • Corona SDK

I haven't touched my code either but save / retrieve data using snapshots is not working if I make a new build.

 

Other people can make a build now with gpgs v1 and save / retrieve data using snapshots is working for them?



[TOPIC: post.html]
#9

genelixis

[GLOBAL: userInfoPane.html]
genelixis
  • Enthusiast

  • 38 posts
  • Corona SDK

A few days ago I emailed code and logs @coronalabs because gpgs save / retrieve data using snapshots stopped working.

 

The answer came from the engineers: 

The problem occurs because I use an old version of gpgs.

I should wait for the new version, gpgs-v2, which wil be released soon.



[TOPIC: post.html]
#10

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

Then you should wait for us to formally release the plugin. Hopefully, it will be soon.

 

Rob



[TOPIC: post.html]
#11

genelixis

[GLOBAL: userInfoPane.html]
genelixis
  • Enthusiast

  • 38 posts
  • Corona SDK

Any news related to gpgs version 2 plugin?



[TOPIC: post.html]
#12

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

My tests have all been successful, but the code for snapshots that I was using doesn't work and needed updated. I'm trying to see how other testers results are going as I'm not privy to those communications.

 

Rob



[TOPIC: post.html]
#13

genelixis

[GLOBAL: userInfoPane.html]
genelixis
  • Enthusiast

  • 38 posts
  • Corona SDK

Same here Rob.

 

Snapshots code doesn't work and community really need it.

 

If there is a change in code or a workaround to make it work could you share it here please?

 

Please keep us updated if any news arise!



[TOPIC: post.html]
#14

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

I'm happy to share the snapshot code from my test app. Again, it's purely test code and my old code-pre-change once worked with the old plugin, so I can't say this will work with the V1 plugin or not.

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()
		local data = gpgs.snapshots.getSnapshot (event.snapshotId)
		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


local function openSnapshot()
	print("Opening snapshot")
	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
		local snapContent = gpgs.snapshots.getSnapshot(event.snapshotId).contents
		snapContent.write(data) -- Write new data as a JSON string into the snapshot
		gpgs.snapshots.save({
			snapshotId = event.snapshotId,
			description = 'Save slot ' .. snapshotFilename,
			listener = gpgsSnapshotAfterSaveListener
		})
	end
end

local function saveSnapshot()
	print("saving snapshhot")
	gpgs.snapshots.open({ -- Open the save slot
		filename = snapshotFilename,
		create = true, -- Create the snapshot if it's not found
		listener = gpgsSnapshotOpenForSaveListener
	})
end

There are still some issues we are working on with the testers so even if you managed to get access to the plugin when it was inadvertently made available, I still wouldn't release against the V2 plugin until we say it's ready.

 

Rob



[TOPIC: post.html]
#15

genelixis

[GLOBAL: userInfoPane.html]
genelixis
  • Enthusiast

  • 38 posts
  • Corona SDK

I had this for gpgs version 1 and used to work (now it's broken) like charm.

https://forums.coronalabs.com/topic/67896-how-to-implement-gpgs-plugin/

 

I can see the changes in your code but it would be better to make it work exactly as version 1.

 

Any chance for ETA? Days? Weeks?


  • Sheekore likes this

[TOPIC: post.html]
#16

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

This is tough to answer because "weeks" could mean anywhere between 2-8 weeks and I don't think it will be anywhere in the 4-8 week range, but if I say "days", in particular with the weekend in the way, it would set your expectations that it could be as early Monday or Tuesday and I don't think that's realistic either. 

 

Have you tried the code above with the V1 plugin?

 

Rob



[TOPIC: post.html]
#17

genelixis

[GLOBAL: userInfoPane.html]
genelixis
  • Enthusiast

  • 38 posts
  • Corona SDK

I don't know why the code from the link in my previous post stopped working the last weeks but I tried your code with ver1 plugin.

 

Did some changes and now I'm able to open snapshots.

 

Trying to do the same for saving snapshots too.

 

--edit

Saving works too, thnx Rob!



[TOPIC: post.html]
#18

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 520 posts
  • Corona SDK

@Rob, any idea when this will be out of Beta?
FYI, my new app has about 500 installs with no ANRs and no crashes. You and your team deserves big time kudos!

[TOPIC: post.html]
#19

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

@troylyndon we announced it last week. It's not really in beta and should be a drop-in replacement. However, there are some reports on another thread of it not working. I would invite you to give it a try and help us identify if there are problems. Just make sure to test it before making a public release.

 

Rob



[TOPIC: post.html]
#20

Sheekore

[GLOBAL: userInfoPane.html]
Sheekore
  • Enthusiast

  • 79 posts
  • Corona SDK

I am using gpgs v1. My snapshot functionality used to work before now it is not working anymore. No code changes were made from my side. Only the corona version was changed. 

I have tried gpgs v2 as a drop in replacement but the login pop up doesn't even show and I can't see any errors also so just reverted back to v1 again. 

Currently building with 2018.3397. 



[TOPIC: post.html]
#21

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

Can you compare your snapshot code to this?
 

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")
	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
		gpgs.snapshots.save({
			snapshot = event.snapshot,
			description = 'Save slot ' .. snapshotFilename,
			listener = gpgsSnapshotAfterSaveListener
		})
	end
end

function myData.saveSnapshot()
	print("saving snapshhot")
	gpgs.snapshots.open({ -- Open the save slot
		filename = snapshotFilename,
		create = true, -- Create the snapshot if it's not found
		listener = gpgsSnapshotOpenForSaveListener
	})
end

Apparently, there were multiple ways to do snapshots. 

 

Rob



[TOPIC: post.html]
#22

Sheekore

[GLOBAL: userInfoPane.html]
Sheekore
  • Enthusiast

  • 79 posts
  • Corona SDK

@Rob

Yes my snapshot code is very similar to your one. The only difference is that I don't have myData.savesnapshot() as a separate function. I have used the code of this how to implement gpgs post. 

During pre-launch test on developer console, one instance of an error was found, here is the message:
 

FATAL EXCEPTION: main
Process: com.sheekore.games.sentioTapEmoji, PID: 12290
java.lang.NullPointerException: value == null
    at java.util.Hashtable.put(Hashtable.java:362)
    at plugin.gpgs.Utils.gameToHashtable(Utils.java:380)
    at plugin.gpgs.Utils.snapshotMetadataToHashtable(Utils.java:444)
    at plugin.gpgs.Snapshots$LoadSnapshotsResultCallback.onResult(Snapshots.java:412)
    at plugin.gpgs.Snapshots$LoadSnapshotsResultCallback.onResult(Snapshots.java:389)
    at com.google.android.gms.common.api.internal.BasePendingResult$CallbackHandler.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5459)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)


[TOPIC: post.html]
#23

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

I don't know where the snapshot code in that forum post originated, it almost looks like it's your original code. The code I used to have wasn't working either. The engineer who built the plugin provided me with the updated code which I tested with both V1 and V2 of the plugin. 

 

I'll share this with Engineering.

 

Rob



[TOPIC: post.html]
#24

Sheekore

[GLOBAL: userInfoPane.html]
Sheekore
  • Enthusiast

  • 79 posts
  • Corona SDK

@Rob

Thank you for having a look into this issue.



[TOPIC: post.html]
#25

Sheekore

[GLOBAL: userInfoPane.html]
Sheekore
  • Enthusiast

  • 79 posts
  • Corona SDK

@Rob

I have updated the snapshot code. I am trying gpgs.v2 plugin, but it seems I can't login. gpgs.isConnected() is giving false always but event.phase in gpgsLoginListener function is saying 'logged in'. The pop up that normally used to show in gpgs V1 is not showing here. 

here is how I implemented the login functionality. With gpgs V1 it works but when I add v2, the login doesn't work anymore. Are there any changes to be made?

local gpgs = require( "plugin.gpgs.v2" )
local function toggleGPGSToLogin( self, event )

  if ( gpgs.isConnected() ) then
    gpgsLoggedOutButton.isVisible = false
    gpgsLoggedInButton.isVisible = true

    local tempGameData = loadsave.loadTable( "gameData.json" )

    -- download snapshot
    local function gpgsSnapshotOpenForReadListener( event )

      if not event.isError then
        -- local retrievedData = event.snapshot.contents.read() 
        local retrievedData = gpgs.snapshots.getSnapshot (event.snapshotId)

        local gameData, pos, msg = json.decode( retrievedData )
        if not gameData then
          toast.show('Decoding failed.' ..tostring(pos)..": "..tostring(msg) ) 

        else  

          if ( tempGameData.inGameAnalyticsTotalGamePlayed < gameData.inGameAnalyticsTotalGamePlayed  ) then
            -- save table from the gpgs server
            loadsave.saveTable( gameData, "gameData.json" ) 

          else
            -- upload the offline gameplayed to GPGS server
            local gameData = loadsave.loadTable( "gameData.json" ) -- loading gameData from phone
            -- save snapshots
            local function gpgsSnapshotOpenForSaveListener( event )

              if not event.isError then

                local snapContent = gpgs.snapshots.getSnapshot(event.snapshotId).contents
                snapContent.write( json.encode(gameData) ) -- Write new gameData as a JSON string into the snapshot
                gpgs.snapshots.save({
                    snapshotId = event.snapshotId,
                    description = "Game scores",
                    image = { filename = "EmojiCrushShare.png", baseDir = system.ResourceDirectory },
                  })
              end
            end -- gpgsSnapshotOpenForSaveListener func END

            gpgs.snapshots.open({  -- Open the save slot
                filename = snapshotFileName,
                create = true,  -- Create the snapshot if it's not found
                conflictPolicy = "most recently modified",
                listener = gpgsSnapshotOpenForSaveListener
              })

          end -- (tempInGameAnalytics.totalGamePlayed < inGameAnalytics.totalGamePlayed)  conditional END
        end -- not inGameAnalytics conditional END
      end -- event.iserror conditional END

    end --gpgsSnapshotOpenForReadListener func END

    gpgs.snapshots.open({
        filename = snapshotFileName,
        conflictPolicy = "most recently modified",
        listener = gpgsSnapshotOpenForReadListener
      })

  end -- gpgs.isConnected() conditional END
end -- toggleGPGSToLogin func END


local function gpgsLoginListener( event )

  gameData.gpgsDataUserPref = event.phase
  print ("gpgsLoginListener")
  print (event.phase)
  loadsave.saveTable( gameData, "gameData.json" )
  toggleGPGSToLogin()

  if event.isError then
    toast.show("Sign in problem: Check network connection.")
  end -- event.isError conditional END
end

local function onGpgsLoginButtonTap( self, event )
          print ("onGpgsLoginButtonTap")
          print (gpgs.isConnected())

          if (gpgs.isConnected()) then
            --logout
            gpgs.logout()
            gameData.gpgsDataUserPref = "logged out"
            loadsave.saveTable( gameData, "gameData.json" )
            gpgsLoggedOutButton.isVisible = true
            gpgsLoggedInButton.isVisible = false

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

          end -- login or logout conditional END
          return true
        end -- onGpgsLoginButtonTap func END

        gpgsLoggedInButton:addEventListener( "tap", onGpgsLoginButtonTap )
        gpgsLoggedOutButton:addEventListener( "tap", onGpgsLoginButtonTap )



[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]