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.
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.
I’m integrating this extension now and can’t seem to get a response from gamekit.gc_signin().
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
else
gamekit_is_logged_in = event.type == "authenticated" -- Player was silently logged in
end
end
print( "gamekit.gc_signin()", on_gc_signin )
gamekit.gc_signin(on_gc_signin)
end
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 ).
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.
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.
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.
Hi @totebo , unfortunately all my development projects are on hold during this current state of endless lockdowns, supply chain issues and vax shunning. I am in the process of moving to another state that has more freedoms than California. This transition is my main focus for at least the next 6 months.
The extension in this thread has quite a bit more ambition to cover more GK features. Would be really interesting if the multiplayer & cloud save stuff works.
Thanks. That’s the one I used in a previous game, and it worked great.
Was testing the waters since this feels more feature complete, but it’s also not building in 1.4.2