Lime native extension for Apple Sign-In


Apple is forcing us (more recently) to support “Sign-In with Apple” next to “Connect with Facebook”, if we have the latter feature in our games.

I’ve written iOS Native extensions before (using various native SDKs), but all were following a very specific pattern, consisting mainly of defining some static functions inside a namespace, which can be called from Haxe via Lib.load(); As long as all the native SDK code I needed could be nicely encapsulated in those static methods, I was fine.

But for Apple Sign-in, the Objective-C examples I’ve managed to find (like this one: make use of a custom UIViewController implementation to define some delegates on it, implementing the ASAuthorizationControllerDelegate and ASAuthorizationControllerPresentationContextProviding interfaces.

Basically I could start the sign-in process from a static method, but then I have to pass a .delegate and a .presentationContextProvider to an ASAuthorizationController object there, and that object should implement those two interfaces mentioned above. And I think it also has to be some sort of display context in which the system can present the authorization interface to the user i.e. an UIViewController maybe?

I know how to obtain an UIViewController doing [[[UIApplication sharedApplication] keyWindow] rootViewController], but I don’t know how to get those delegates into it.

My understanding of Objective-C is very shaky at best. I also have no idea how I could use Swift to make iOS Lime Native Extensions, but that’s a bit of a divergent topic and I’m not sure it would really help with the issue at hand.

The thing is that this requirement is suddenly a showstopper for anybody who makes games with OpenFL and wants to publish them on AppStore, but support Facebook login as an option, as they now must get “Sign-in with Apple” on board too. That’s why I hope my question would possibly help many others, if we can find an answer together.

Thank you!

You can create and keep objects at obj-c part… so later, when you call static methods again - you`ll just receive them and continue to use. Just remove them when all is done

You can add them to your top vc/window, for example. check objc_getAssociatedObject / objc_setAssociatedObject, they can “sync” lifetime of objects with retain/release strategy

Thanks for the suggestion, I’ll try that.

You can try this extension as well:
We are using it for our game (but we are using NME).

1 Like

Amazing, that seems to be exactly what we need! Shouldn’t be any significant difference between NME and Lime, we were having troubles mostly on the Objective C side. Thanks a lot!