Skip to main content
Version: 5.11.8

AppleLogin

public bool AppleLogin(string webClientId, out string errorMessage, bool isCallbackInMainThread, AppleLoginCallback callback);
public bool AppleLogin(string webClientId, out string errorMessage, bool isCallbackInMainThread, int left, int top, int right, int bottom, AppleLoginCallback callback);

Parameters

ValueTypeDescriptionDefault
identifierstringCertificates, Identifiers & Profiles page > Identifiers > Identifier created from Services IDs-
errorMessageout StringAn empty value for success / error information for failure-
isCallbackInMainThreadboolIf true, the callback runs in the main Unity thread. If false, it runs in an external thread.-
leftintLeft margin px0
topintTop margin px0
rightintRight margin px0
bottomintBottom margin px0
callbackAppleLoginCallbackCallback methods called upon successful Apple login-

Attempts Apple login. The result can be checked through the callback event.
identifier has the value as shown below.

Main thread and external thread

When using Unity, if an object or function created using UnityEngine or UnityEngine.UI is called from an external thread, an exception occurs.

When a callback is called to the main thread, a crash may occur if numerous objects are created in the callback, synchronous form BACKND functions cause the game to stop temporarily, or if a heavy action takes place.

AppleLoginCallback

This is a handler that is called automatically when a token has been issued. It can be assigned as a variable for AppleLogin.

public delegate void AppleLoginCallback(string token);
private static AppleLoginCallback OnAppleLogin;

OnCloseButtonClick

This is a handler that is called when you quit Apple login with the button on the top right.

public delegate void CloseButtonClickCallback();
public static CloseButtonClickCallback OnCloseButtonClick;

Example

    public void StartAppleLogin() {
#if UNITY_ANDROID || UNITY_EDITOR
TheBackend.ToolKit.AppleLogin.Android.OnCloseButtonClick = () => {
Debug.Log("The window has been closed");
};

TheBackend.ToolKit.AppleLogin.Android.AppleLogin("com.thebackend.testapp.applelogin", out var error, true, token => {
Debug.Log("Token : " + token);
Debug.Log("A token has been issued. You can now log in.");

// Warning! : Do not call synchronous methods as shown below.
// var bro = Backend.BMember.AuthorizeFederation(token, FederationType.Apple);

// Call asynchronous methods as shown below.

Backend.BMember.AuthorizeFederation(token, FederationType.Apple, callback => {
Debug.Log("Apple login result : " + callback);
});
});

if (string.IsNullOrEmpty(error) == false) {
Debug.Log("Error : " + error);
}
#endif
}

Error cases

(AuthorizeFederation method) When the entered identifier and the identifier value set from the console do not match
statusCode : 401
errorCode BadUnauthorizedException