This is a FREE, UNOFFICIAL, MIT licensed, open source plugin, to support Sign In With Apple in iOS, tvOS, macOS and visionOS. The plugin is developed by the community, and it´s not the same one as the official plugin from Unity available in the Asset Store.
The main purpose for this plugin is to expose Apple’s newest feature, Sign in with Apple, to the Unity game engine. The plugin started development as soon as Apple announced the feature and has been around for a while already. Version v1.2.0 was released recently, adding macOS support, that´s why I decided to also post it here as well.
On WWDC19, Apple announced Sign in with Apple, and on top of that, they announced that every iOS/tvOS/macOS Application that used any kind of Third party sign-ins (like Sign in with Facebook, or Sign in with Google), will have to support Sign in with Apple in order to get approved for the App Store, making it mandatory.
The plugin is available on GitHub:
Features
Support for iOS/tvOS/macOS/visionOS
Supports Sign in with Apple, with customizable scopes (Email and Full name).
Supports Get Credential status (Authorized, Revoked and Not Found).
@lupidan this looks really cool, thank you for sharing it. Does the keychain feature mean that if you load the same game where the user already authenticated on a different device with the same itunes account that the user will already be considered authenticated (or that userID will be available) on that device as well?
Hi @James15478
Once you login using Sign In With Apple in device A, when you go and install the app in device B, Quick Login should detect your Apple ID was already used for that app, and allow to login again instead of creating a new account. The result of it will be the same user ID.
Thanks @lupidan . I noticed you recommend quick login at every app open. But I haven’t really seen this in other apps, they just open without asking for re-authorization (re-signing in). Do you think those apps just save the credentials locally then?
After a successful login/quick login in a device, you get an Apple User ID.
You should save in in the device for the future, and provide it to GetCredentialState to know the status of the user.
There is a diagram describing the flow in the documentation. Please learn about it:
Thanks @lupidan . I’m experimenting with it now. Just using the sample scene atm. It all worked as expected, except after a few tries of revoking permissions and returning to the app, at one point I am just continuingly authorized (I open the app and the user ID shows). I check on device for “Apps using Apple ID” and my app is no longer there, since I revoked permissions, but still shows as authorized in the Unity app. If I reinstall, it seems the quick login pops up as opposed to the “full” login (where it asks for name etc). Do you know why that might be?
If the Sign in with Apple credentials for your app are not granted or revoked, QuickLogin will fail with an error, which is expected. That’s when you redirect the user to the login screen for a Sign In With Apple scenario
If the Sign in with apple credentials are still valid, QuickLogin will display a screen with just the option to proceed (since they were given in the past for yout app and they are still valid)
Basically, if you don’t see the option to give the name, as well as the email selection option, it’s a QuickLogin scenario, where credentials already given in the past, period.
Hi! I’m developing a sign logic for our project using your plugin with Firebase.
To be able to create and login with Apple on Firebase, their documentation requires that we use “appleIdToken” and “rawNonce”.
I’m assuming “appleIdToken” would be the “appleUserId” used through out your plugin to identify the user, correct?
How can I request the “rawNonce” mentioned in Firebase documentation?
Hi @lupidan , Thanks for a great plugin! I’m using Gamesparks (www.gamesparks.com) and they require the authorizationCode everytime i want to retrieve a user account.
As far as I know, the authorization code is something that’s only provided to you when requesting access with Apple actively (first login only) which will trigger the authentication window.
After the first login/sign in, and successfuly first login/sign in with Gamesparks, your user should be saved in the device and you should just check if the apple user ID is still valid in order to keep that user logged in, or force a logout. (With the CheckCredentialStatus call)
I made a diagram on how I think it should work, make sure you go through it, and adapt it to the needs of Gamespark:
It’s been a while since I updated the thread. So here is the missing changelog since 1.3.0.
I plan to update the asset store version at some point, Unity’s publishing tools don’t get along well with the project. In the meantime, you can keep using the unity package manager, or download the unity package manually from the releases page on github.
[1.4.2] - 2020-07-17 Changed
Handles empty NSPersonNameComponents sent by Apple when not requesting a name, to be nil natively.
Updated MacOSAppleAuthManager.bundle with the updated native code
Removed
Removes FixSerializationForFullPersonName and any usage of it when deserializing to avoid NRE
[1.4.1] - 2020-11-28 Added
Updates plugin’s main MacOSAppleAuthManager.bundle to support Apple Silicon arm64 architecture
Changed
Updates some elements in the dedicated macOS documentation file that were incorrect
[1.4.0] - 2020-10-18 Added
Adds static class AppleAuthMacosPostprocessorHelper, so now there should always be an AppleAuth.Editor namespace independent of the current platform.
Adds static method to AppleAuthMacosPostprocessorHelper, FixManagerBundleIdentifier is a method to change the plugin’s bundle identifier to a custom one based on the current project’s application identifier. This should avoid CFBundleIdentifier collision errors when uploading to the MacOS App Store.
Adds enum value for LoginOptions to not request full name or email, LoginOptions.None.
Changed
Updates sample code Postprocessor script to support the new recommended post processing for macOS builds
Thanks for creating this package! It all seems quite straightforward, but i have one problem: i can’t figure out where to find the PayloadDeserializer – i get this error:
The type or namespace name ‘PayloadDeserializer’ could not be found (are you missing a using directive or an assembly reference?)
… so it seems like i’m missing a “using directive”, but i’m having the same as in your example code. And pointers on how i can solve this would be appreciated. Thanks!
IOS build failing with Undefined symbols for architecture arm64
Undefined symbols for architecture arm64:
“_UnitySignInWithApple_Login”, referenced from:
_SignInWithApple_LoginInternal_mF47ED0923886387AC79573DD52A2A75D6D8F1FFD in Assembly-CSharp38.o
_SignInWithApple_UnitySignInWithApple_Login_m5A2EF436C683C71D2D6E034D838FD05FDA6F6D3C in Assembly-CSharp38.o
(maybe you meant: _SignInWithApple_UnitySignInWithApple_Login_m5A2EF436C683C71D2D6E034D838FD05FDA6F6D3C)
“_UnitySignInWithApple_GetCredentialState”, referenced from:
_SignInWithApple_GetCredentialStateInternal_mE7725CD83B2C11D10EC76EB24DC795ADBE20DB27 in Assembly-CSharp38.o
_SignInWithApple_UnitySignInWithApple_GetCredentialState_m2DC81A39E66199A01BC2B1B0CBD3C0EB811137D8 in Assembly-CSharp38.o
(maybe you meant: _SignInWithApple_UnitySignInWithApple_GetCredentialState_m2DC81A39E66199A01BC2B1B0CBD3C0EB811137D8)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Those symbols are from Unity’s official Sign in With Apple package. This package is for a completely different plugin.
Please refer your request to Unity support.