iOS Registration and Authentication
Registers and authenticates using Apple ID.
Register Apple Authentication SDK
- Download the Apple Authentication Unity Package.
- Import Apple Authentication Unity Package into your project.
Download Apple Authentication Unity Package
Call Information
AccountSocialSignIn(string appleIdToken, string accountType, PlayNANOODelegate callback) {}
Call Information Details
Parameter | Description | Type |
---|---|---|
appleIdToken | Apple ID Token | String |
accountType | Account type | String |
callback | Communication result | PlayNANOODelegate |
Source Code
using AppleAuth;
using AppleAuth.Native;
using AppleAuth.Enums;
using AppleAuth.Extensions;
using AppleAuth.Interfaces;
using PlayNANOO;
public class PlayNANOOExample : MonoBehaviour
{
IAppleAuthManager _appleAuthManager;
Plugin plugin;
void Start()
{
plugin = Plugin.GetInstance();
if (AppleAuthManager.IsCurrentPlatformSupported)
{
var deserializer = new PayloadDeserializer();
_appleAuthManager = new AppleAuthManager(deserializer);
}
}
private void Update()
{
_appleAuthManager?.Update();
}
public void SignIn()
{
var loginArgs = new AppleAuthLoginArgs();
this._appleAuthManager.LoginWithAppleId(
loginArgs,
credential =>
{
var appleIdCredential = credential as IAppleIDCredential;
if (appleIdCredential != null)
{
string idToken = Encoding.UTF8.GetString(appleIdCredential.IdentityToken, 0, appleIdCredential.IdentityToken.Length);
plugin.AccountSocialSignIn(idToken, Configure.PN_ACCOUNT_APPLE_ID, (status, errorCode, jsonString, values) =>
{
if (status == Configure.PN_API_STATE_SUCCESS)
{
Debug.Log(values["access_token"].ToString());
Debug.Log(values["refresh_token"].ToString());
Debug.Log(values["uuid"].ToString());
Debug.Log(values["openID"].ToString());
Debug.Log(values["nickname"].ToString());
Debug.Log(values["linkedID"].ToString());
Debug.Log(values["linkedType"].ToString());
Debug.Log(values["country"].ToString());
}
else
{
if (values != null)
{
if (values["ErrorCode"].ToString() == "30007")
{
Debug.Log(values["WithdrawalKey"].ToString());
}
else if (values["ErrorCode"].ToString() == "70002")
{
Debug.Log(values["BlockKey"].ToString());
}
else
{
Debug.Log("Fail");
}
}
else
{
Debug.Log("Fail");
}
}
});
}
},
error =>
{
// Something went wrong
var authorizationErrorCode = error.GetAuthorizationErrorCode();
}
);
}
}
Communication Result
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"Token" : {
"AccessToken" : "String",
"RefreshToken" : "String"
},
"Player" : {
"UserUniqueID" : "String",
"OpenID" : "String",
"Nickname" : "String",
"LinkedID" : "String",
"LinkedType" : "String",
"Country" : "String"
}
}
Response Information Details
Data Key | Description | Type |
---|---|---|
Token.AccessToken | Player access token | string |
Token.RefreshToken | Player refresh token | string |
Player.UserUniqueID | Player's unique ID | string |
Player.OpenID | Player's unique open ID | string |
Player.Nickname | Player's nickname | string |
Player.LinkedID | Player's linked ID | string |
Player.LinkedType | Player's link type | string |
Player.Country | Player's country code | string |
WithdrawalKey | Account withdrawal query key | string |
Error Information
No player information exists
ErrorCode : 30000
ErrorMessage : NotFoundAccountException
Player information is being used on another device
ErrorCode : 30006
ErrorMessage : DuplicatedDeviceException
Player has requested withdrawal
ErrorCode : 30007
ErrorMessage : WithDrawalException