百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

apple-signin-unity

> 编程语言
开源

Unity 插件,用于支持使用 Apple ID 登录

744 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Unity 插件,用于支持使用 Apple ID 登录

Sign in with Apple Unity Plugin

by Daniel Lupiañez Casares

  • Overview
    • Features
      • Native Sign in with Apple
    • Installation
      • Unity Package Manager
        • Install via Git URL
        • Install via OpenUPM
      • Unity Package File
    • Plugin setup (iOS/tvOS)
      • Programmatic setup with a Script
      • Manual entitlements setup
      • Enabling Apple capability
      • Final notes regarding setup
    • Plugin setup (macOS)
    • Implement Sign in With Apple
      • Initializing
      • Perform Sign In With Apple
      • Quick login
      • Checking credential status
      • Listening to credentials revoked notification
      • Nonce and State support for Authorization Requests
    • FAQ
      • Does it support landscape orientations?
      • How can I Logout? Does the plugin provide any Logout option?
      • I am not getting a full name, or an email, even though I am requesting them in the LoginWithAppleId call
      • Is it possible to NOT request the user's email or full name?
      • Does the plugin use UnitySendMessage?
      • Why do I need to call Update manually on the AppleAuthManager instance?
      • What deserialization library does it use by default?
      • Any way to get a refresh token after the first user authorization?
      • I am getting a CFBundleIdentifier Collision error when uploading my app to the macOS App Store

Overview

Sign in with Apple plugin to use with Unity 3D game engine.

This plugin supports the following platforms:

  • iOS
  • macOS Intel x86_64 AND Apple Silicon arm64(Experimental) (NOTES)
  • tvOS (Experimental)
  • visionOS (Experimental)

The main purpose for this plugin is to expose Apple's newest feature, Sign in with Apple, to the Unity game engine.

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.

Features

Native Sign in with Apple

  • Support for iOS

  • Support for macOS: Intel x86_64 AND Apple Silicon arm64(Experimental) (NOTES)

  • Support for tvOS (Experimental)

  • Support for visionOS (Experimental)

  • Supports Sign in with Apple, with customizable scopes (Email and Full name).

  • Supports Get Credential status (Authorized, Revoked and Not Found).

  • Supports Quick login (including iTunes Keychain credentials).

  • Supports adding Sign In with Apple capability to Xcode project programatically in a PostBuild script.

  • Supports listening to Credentials Revoked notifications.

  • Supports setting custom Nonce and State for authorization requests when Signing In, and attempting a Quick Login.

  • NSError mapping so no details are missing.

  • NSPersonNameComponents support (for ALL different styles).

  • Customizable serialization (uses Unity default serialization, but you can add your own implementation)

Installation

Current stable version is 1.5.0

There are two options available to install this plugin. Either using the Unity Package Manager, or the traditional .unitypackage file.

Unity Package Manager

Install via Git URL

Available starting from Unity 2020.3.

Just add this line to the Packages/manifest.json file of your Unity Project:

"dependencies": {
    "com.lupidan.apple-signin-unity": "https://github.com/lupidan/apple-signin-unity.git?path=Source#1.5.0",
}

Install via OpenUPM

The package is available on the openupm registry. You can install it via openupm-cli.

openupm add com.lupidan.apple-signin-unity

Unity Package File

  1. Download the most recent Unity package release here
  2. Import the downloaded Unity package in your app. There are two main folders:
  • The AppleAuth folder contains the main plugin.
  • The AppleAuthSample folder contains sample code to use as a reference, or to test the plugin.

Plugin setup (iOS/tvOS)

To be able to use Apple's platform and framework for Authenticating with an Apple ID, we need to set up our Xcode project. Two different options are available to set up the entitlements required to enable Apple ID authentication with the iOS SDK.

Programmatic setup with a Script

RECOMMENDED

This plugin provides an extension method for ProjectCapabilityManager (docs), used to add this entitlement programatically after an Xcode build has finished.

Simply create a Post Processing build script (more info) that performs the call. If you already have a post process build script, it should be simple to add to your code.

The provided extension method is AddSignInWithAppleWithCompatibility.

Sample code:

…

Manual entitlements setup

The other option is to manually setup all the entitlements in our Xcode project. Note that when making an iOS Build from Unity into the same folder, if you choose the option to overwrite, you will need to perform the Manual setup again.

  1. In your generated Xcode project. Select the main app Unity-iPhone target and select the option Signing And Capabilities. You should see there an option to add a capability from a list. Just locate Sign In With Apple and add it to your project.

  2. This should have added an Entitlements file to your project. Locate it on the project explorer (it should be a file with the extension .entitlements). Inside it you should see an entry like this one:

  3. You need to import the AuthenticationServices.framework library in the Build Phases->Link Binary with Libraries. If you are targeting older iOS versions, mark the library as Optional.

    For Unity 2019.3 onwards, add it to the UnityFramework target

    For previous Unity versions, add it to the main Unity-iPhone target

Enabling Apple capability

You will also need to setup everything in the Apple's developer portal. More information can be found here. Please remember this plugin only supports native Sign In With Apple on iOS (no REST API support).

There is also a Getting Started site.

Final notes regarding setup

The AuthenticationServices.framework should be added as Optional, to support previous iOS versions, avoiding crashes at startup.

The provided extension method uses reflection to integrate with the current tools Unity provides. It has been tested with Unity 2020.x, 2021.x, 2022.x and 6000.0. But if it fails on your particular Unity version, feel free to open a issue, specifying the Unity version.

Plugin setup (visionOS)

On visionOS, the setup is pretty much the same as the iOS/tvOS setup. However, due to how Unity's visionOS project is exported, you need to adapt the Postprocess code to find the proper xcode project filename:

if (target == BuildTarget.VisionOS) { projectPath = projectPath.Replace("Unity-iPhone.xcodeproj", "Unity-VisionOS.xcodeproj"); }

Plugin setup (macOS)

An unsigned precompiled .bundle file is available. The precompiled .bundle should support both architectures: Intel x86_64 & Apple Silicon arm64(Experimental). The bundle should be automatically included in your macOS builds. However that .bundle needs to be modified to avoid issues when uploading it to the MacOS App Store.

In particular, the bundle identifier of that .bundle needs to be modified to a custom one.

To automate the process, there is a helper method that will change the bundle identifier to one based on your project's application identifier. You should call this method on a Postprocess build script of your choice.

using AppleAuth.Editor;

public static class SignInWithApplePostprocessor
{
    [PostProcessBuild(1)]
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
        if (target != BuildTarget.StandaloneOSX)
            return;

        AppleAuthMacosPostprocessorHelper.FixManagerBundleIdentifier(target, path);
    }
}

The Xcode project with the source code to generate a new bundle file is available at MacOSAppleAuthManager/MacOSAppleAuthManager.xcodeproj

To support the feature, the app needs to be codesigned correctly, including the required entitlements. For more information regarding macOS codesign, please follow this link.

Implement Sign in With Apple

Currently, it seems Sign In With Apple does not work properly in the simulator. This needs testing on a device with an iOS 13 version.

An overall flow of how the native Sign In With Apple flow could work is presented in this diagram.

Initializing

…

Perform Sign In With Apple

:warning: You will receive users's email and name ONLY THE FIRST TIME THE USER LOGINS. Any further login attempts will have a NULL Email and FullName, unless you revoke the credentials

If you want to Sign In and request the Email and Full Name for a user, you can do it like this:

…

Quick login

This should be the first thing to try when the user first runs the application.

If the user has previously authorized the app to login with Apple, this will open a native dialog to re-confirm the login, and obtain an Apple User ID.

If the credentials were never given, or they were revoked, the Quick login will fail.

…

Note that, if this succeeds, you will ONLY receive the Apple User ID (no email or name, even if it was previously requested).

IOS Keychain Support

When performing a quick login, if the SDK detects IOS Keychain credentials for your app, it will return those.

Just cast the credential to IPasswordCredential to get the login details for the user.

Checking credential status

This is used to verify that an Apple User ID is still valid.

Given an userId from a previous successful sign in. You can check the credential state of that user ID like so:

…

Listening to credentials revoked notification

It may be that your user suddenly decides to revoke the authorizati

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#apple-sign-inapple-signiniosunity

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言