Google Play Game Services

We’re happy to finally announce the availability of the first public release of the long awaited Google Play Game Services extension for Android! The extension does currently support authentication and cloud save and it has been tested in production in Look Your Loot by @Dragosha (thanks!).

We are currently looking for community contributors to add more functionality such as achievements and leaderboards. Head to the GitHub page of the extension to start contributing or to learn more!

30 Likes

Does this currently support achievements?

Looks like no?

https://developers.google.com/games/services/android/achievements

I’ll give it a shot…

3 Likes

I’m afraid it doesn’t support it yet.

It would be GREAT to have leaderboards and achievements on Google Play! :smiley:

2 Likes

Did you have time to work on this? I may have a little bit of time next week and could take a look at it as well.

4 Likes

Have not yet, please do!

2 Likes

Did you get to start on this? Planning a new project and would love to be able to include leaderboard and achievements on Google Play.

Yes, I started but got sidetracked by other things. Will pick it up again next week.

2 Likes

I am working on this now. For real.

5 Likes

Achievement support is done now. API:

achievement_reveal(id)
achievement_unlock(id)
achievement_set(id, steps)
achievement_increment(id, steps)
achievement_show()
achievement_get() -- async listener callback with list of achievements. json.decode() it

It’s available from this dev branch: https://github.com/defold/extension-gpgs/tree/dev-achievements

11 Likes

Amazing!This is really useful. Will you have time to look at the leaderboards too?

1 Like

Yes, I will look into leaderboards next week.

5 Likes

tumblr_n06g3k5D9Y1sip3f6o1_250

It is time. I’ll start working on leaderboards today.

Has anyone had time to check out the achievement API I added?

9 Likes

I’ll try it out this weekend.

1 Like

I’ve added support for leaderboards as well. It needs further testing and has been released as a pre-release on GitHub:

gpgs.achievement_reveal(achievement_id)
gpgs.achievement_unlock(achievement_id)
gpgs.achievement_set(achievement_id, steps)
gpgs.achievement_increment(achievement_id, steps)
gpgs.achievement_show()
gpgs.achievement_get() -- async listener callback
gpgs.leaderboard_submit_score(leaderboard_id, score)
gpgs.leaderboard_get_top_scores(leaderboard_id, time_span, collection, max_results) -- async listener callback
gpgs.leaderboard_get_player_centered_scores(leaderboard_id, time_span, collection, max_results) -- async listener callback
gpgs.leaderboard_show(leaderboard_id)
gpgs.leaderboard_get_player_score(leaderboard_id) -- async listener callback
5 Likes

testing achievements right now and everything but increment seems to work. Maybe im doing something wrong, but the achievement stays at 0%, incrementing does nothing.

Please create a ticket in the GitHub repository.

Added support for events:

gpgs.event_increment(event_id, amount)
gpgps.event.get() -- async
3 Likes

What’s the normal way to authenticate? @Dragosha

Should I do it at start of the app, or have them press a button to sign into Google Play GS?

function gpgs_callback(self, message_id, message)
	if message_id == gpgs.MSG_SIGN_IN or message_id == gpgs.MSG_SILENT_SIGN_IN then
		if message.status == gpgs.STATUS_SUCCESS then
			print("gpgs.get_id()", gpgs.get_id())
			print("gpgs.get_display_name()", gpgs.get_display_name())

			if sys.get_config("gpgs.client_id") then
				print("id_token: ", gpgs.get_id_token())
				print("auth_code: ", gpgs.get_server_auth_code())
			end
		end
	end
	print("gpgs.is_logged_in()", gpgs.is_logged_in())
end

function init(self)
	if gpgs then
		gpgs.set_callback(gpgs_callback)
		gpgs.silent_login()
		timer.delay(2, false, function() 
			if not gpgs.is_logged_in() then
				gpgs.login()
			end
		end)
	end
end

Not sure what I’m doing wrong. The signin UI shows for a moment then auto-dismisses. I did download
Look, Your Loot! and it seemed to sign in properly.

DEBUG:SCRIPT: gpgs_callback	2
DEBUG:SCRIPT: 
{ --[[0x70dc41c2f0]]
  status = 2,
  error = "Silent sign-in failed"
}
DEBUG:SCRIPT: gpgs.is_logged_in()	false
DEBUG:SCRIPT: gpgs_callback	1
DEBUG:SCRIPT: 
{ --[[0x70caeae700]]
  status = 2,
  error = "Sign-in failed"
}
DEBUG:SCRIPT: gpgs.is_logged_in()	false

I have the game.project settings mirroring how the example is set up.

The SHA-1 certificate fingerprint stuff looks to match what’s on the console. Same SHA-1 for App signing and the linked app.

Edit:

It’s suddenly working. Only change I made was to not include the client id in the game.project

Achievements work! :sparkles:

Updated version with achievements enabled is live https://play.google.com/store/apps/details?id=com.subsoap.fsr&hl=en_US

6 Likes