01/10/2025 10:53:00
Apple Channel Description
Apple has started to support Apple ID login since XCode 11. The running iOS system version functions normally in iOS 13 and above; otherwise, the login will return error code 7 (NOT_SUPPORT).
I. Configure Apple Developer Potral
Before implementing the Sign in with Apple function, you need to do the following things in Apple Developer Portal:
- Get Team ID;
- Create client_id used to identify the source of the request when sending a request to Apple;
- For iOS apps, client_id is also App ID (Bundle ID)
- Create a description file
- Create 'key' used to calculate client_secret and the corresponding Key ID;
1.1 Get Team ID
- Log into the Apple Developer Portal and click Account;
- Click Membership in the left sidebar to see Team ID;
1.2 Create App ID
- Log into the Apple Developer Portal and click Account;
- Click Certificates, IDs & Profiles in the left sidebar;
- Click Identifiers in the left sidebar, then click the blue plus sign;
- The first step is to select App IDs, and then click Continue;
- Enter Description and Bundle ID, and check Sign in with Apple under Capabilities;
- Click Continue, and click Register;
For existing App ID, what is needed to do is just to find App ID to which you want to add Sign in with Apple and then check Sign in with Apple under Capabilities.
1.3 Create a description file
- Log into the Apple Developer Portal and click Account;
- Click Certificates, IDs & Profiles in the left sidebar;
- Click Profiles in the left sidebar, then click the blue plus sign;
Select the certificate type and then click Continue
Select the App ID registered in the previous step and then click Continue
Select the signed certificate and then click Continue
Select the device and then click Continue
Name the description file and then click Continue
Download the description file. Click Download
Install the downloaded description file into the development or packaging environment
For the existing description file, what is needed to do is just to add Sign in with Apple in Capabilities of App ID and then edit, save and download it again
1.4 Create Key and Get Key ID
- Log into the Apple Developer Portal and click Account;
- Click Keys in the left sidebar, then click the blue plus sign;
- Enter Key Name and check Sign in with Apple;
- Click Configure next to Sign in with Apple, select the App ID configured with the Sign in with Apple function as Primary App ID, and then click Save;
- Click Continue, and click Register;
- Download the Key file ( You can only download it once. Make sure you don't lose it ) and get Key ID
Configure App ID, Team ID, Key ID as well as the content of the Key file obtained in the above process into the Feiying System when the game accesses the Apple channel.
II. iOS Project Configuration
If a game wants to access 'Sign in with Apple', it must be compiled with Xcode 11. When the running iOS system version is iOS 13 or above, the functions can work normally; otherwise, the sign-in will return error code 7 (NOT_SUPPORT)
2.1 Add Capability in Xcode
2.2 Configure Xcode BuildPhases
Add AuthenticationServices.framework in Xcode BuildPhases and set Status to optional
III. Configure Unity
3.1 Configuration of xx.projmods file of Unity XUPoter
When exporting an XCode project through Unity, you need to configure the projmods file (equivalent to the manual configuration of 2.1)
{
"group": "MSDKApple",
"libs": [],
"frameworks": ["AuthenticationServices.framework:weak"],
"files": [],
"folders": [],
"excludes": [],
"headerpaths":[],
"build_settings": {},
"system_capabilities": {},
"Info.plist":{}
}
3.2 Unity project needs to add Entitlement file
Example: MSDKDevDemo.entitlements
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.applesignin</key>
<array>
<string>Default</string>
</array>
</dict>
</plist>
As for how to add Entitlement file in Unity, please refer to the strategy posted in the Unity forum
https://forum.unity.com/threads/how-to-put-ios-entitlements-file-in-a-unity-project.442277/
IV. Requirements on UI
human-interface-guidelinesis the UI style required by Apple, which has a clear UI requirements. The game needs to pay attention to:
Requirements on the appearance and color of the button
The login button has three appearances: white, bordered white and black. It is required to choose a button appearance that fits the background
White button
Used for a dark or colorful background
Bordered white button
Used for white or light-colored backgrounds that cannot provide sufficient contrast
Black button
Used a white or light background which provides sufficient contrast
Requirements on the button's location
- Use the "Sign in with Apple" button which has the same size as other login buttons
- Avoid scrolling to see the button
- By default, the "Sign in with Apple" button has rounded corners
- In addition, the button cannot have any ratio loss when it is stretched or compressed
- The button needs to be above all other login modes
Other focuses
Apple provides two types of documentation, "Sign in With Apple" and "Continue With Apple", for the login button (Objective-c and Swift native UI components). The game developer can choose the documentation that matches your login experience. The language of the documentation will be localized with the mobile phone system's language
V. Request the user's full name and email
public static void Login(string channel, string permissions = "", string subChannel = "", string extraJson = "")
public static void Login(const String &channel, const String &permissions, const String &subChannel, const String &extraJson)
Parameter Description**
Parameter name | Parameter type | Description |
---|---|---|
channel | string | channel name, filled with "Apple" |
permissions | string | "email , fullName" |
subChannel | string | Leave it blank and use the default value |
extraJson | string | Leave it blank and use the default value |
Apple login will only provide fullName and email when first authorized. MSDK will carry them back through the channelInfo field in the first authorization
channelInfo is a JSON format string, where email and full_name fields are the email and username provided by Apple
The method to get username and password again
In "Settings-Apple ID, Cloud, Media and Purchase Items-Password and Security-Use Your Appid", delete the authorization to the app. After this, when you log in again, Apple will provide username and email again
VI. Third-party error codes
Login
Error code | Error information |
---|---|
1000 | Unknown error |
1001 | The user cancels login |
1002 | Authorization request receives an invalid response |
1003 | Authorization request which is not processed |
1004 | Authorization attempt failed |
Automatic login
Error code | Error information |
---|---|
0 | The user cancels authorization |
2 | iCloud not logged in |
All rights reserved.