Apple GameKit Game Center Extension


The GameKit native extension and demo Defold project I’ve been working on is now released:

It is still a work in progress but the following integrated GameKit features are functional:
Players, Leaderboards, Achievements, View Controllers and Errors.

I’ll be adding Real-Time Matches next.

Possible GameKit features to be integrated: Challenges, Player Invitations, Notifications, Entitlements, Turn-based Games and Save Game Data.

Thanks to @RG1, @Dragosha, @britzl and @sergey.lerg for their public code examples, it really helped me understand how native extensions are done in Defold.

Note, this extension uses Game Center playerID to support lower iOS versions than iOS 13.
As of iOS 13, Game Center playerID is deprecated. It will be replaced with gamePlayerID and teamPlayerID:

I don’t own an iOS 13 device, so I haven’t been able to test what happens to playerID in iOS 13.
If you find any bugs or have any questions please post them here.


GameKit and Google Play Services

Really cool. Please submit it to the asset portal!



I haven’t switched to Defold but my native game uses playerID and I just checked in the iOS 13 Simulator. It is still the same string it’s always been.



Good to know playerID still works in iOS 13 as well. @radiofreelunch, Thanks for the info.



Game Center Real-Time Match features have been added to the extension and pushed to GitHub.

I’ll continue to work on the Game Center Save Game Data features as soon as this Defold bug with iOS entitlements not merging is fixed.



WOW this is great! Thanks a lot

1 Like


I’m integrating this extension now and can’t seem to get a response from

I’ve created a debug build which I’ve uploaded to Testflight. I’m using a sandbox account.

This is the code:

local gamekit_is_logged_in

if gamekit then

	local function on_gc_signin( event ) -- This function is never triggered

		pprint( "	on_gc_signin()", event )
		if event.type == "showSignInUI" then -- Player hasn't previously logged in
			gamekit.gc_show_signin("UI") -- Show UI to log in
			gamekit_is_logged_in = event.type == "authenticated" -- Player was silently logged in

	print( "gamekit.gc_signin()", on_gc_signin )


Any idea where I’m going wrong? The Console doesn’t seem to show a clear error message.

Edit 1: There IS a callback, but the first variable seems to be self, rather than “event”. So the question becomes, which variables are returned by the gc_signin() callback? It doesn’t seem documented here.

Edit 2: Found it in the example project, here. It’s on_gc_signin( self, event ).

1 Like


I’m currently off grid and away from my computer but I will be able to look into your question this Saturday the 25th when I return. In the meantime the example project on GitHub might have a solution for you.

1 Like


Yes, it all works now, thanks! In the end the problem was that I didn’t know what the gc_signin() returned, because it was missing in the documentation. A quick check in the example made it clear.



Good point, I’ll add a description for the self parameter in the callback functions to the documentation.
Glad to hear you were able to solve your problem from looking at the example code.



I trigger the sign in as the app starts. If the player cancels this, is there a way to trigger it again?

Calling gamekit.gc_signin() from a button in game returns this message:

ERROR:GAMEKIT: Game Center is enabled, call gc_signin() only one time after your game launches

I also tried to call gamekit.gc_show_signin("UI") resulting in this message:

ERROR:GAMEKIT: You must receive the 'showSignInUI' event before you call gc_show_signin('UI')


Apple won’t allow you to force or nag the local player to sign into game center. If the local player cancels the sign in UI for that session, you could pop up information explaining the benefits the user would get in your game and how to sign into game center through the device’s game center settings.

If the local player cancels the sign in UI 3 consecutive times on 3 consecutive game launches, game center will stop showing the sign in UI at game launch until the local player signs into game center through the device’s game center settings.



Thanks @animonger, that makes sense. So, basically, Apple doesn’t allow more than one sign in prompt per session and, cursed be the mere thought, not more than three in total.

Reading your answer reminded me I have battled with this before. It used to be irreversible, and the player had to wipe the phone to allow logins for a game. At least now you can solve it by using settings to sign in.