Account Registration and Authentication
Use Facebook account for registration and authentication.
Available for both iOS and Android.
Call Information
AccountSocialSignIn(string facebookAccessToken, string accountType, PlayNANOODelegate callback) {}
Call Information Details
Parameter | Description | Type |
---|---|---|
facebookAccessToken | Facebook Access Token | String |
accountType | Account type | String |
callback | Communication Result | PlayNANOODelegate |
Source Code
using PlayNANOO;
using Facebook.Unity;
public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;
void Start()
{
plugin = Plugin.GetInstance();
if (!FB.IsInitialized)
{
FB.Init(OnFBInitComplete, OnFBHideUnity);
}
else
{
FB.ActivateApp();
}
}
void OnFBInitComplete()
{
if (FB.IsInitialized)
{
FB.ActivateApp();
}
else
{
Debug.Log("Failed to Initialize the Facebook SDK");
}
}
void OnFBHideUnity(bool isShow)
{
if (!isShow)
{
Time.timeScale = 0;
}
else
{
Time.timeScale = 1;
}
}
public void FacebookSignIn()
{
var para = new List<string>() { "public_profile", "email" };
FB.LogInWithReadPermissions(para, FacebookAuthCallback);
}
void FacebookAuthCallback(ILoginResult result)
{
if (FB.IsLoggedIn) {
// PlayNANOO Authentication
plugin.AccountSocialSignIn(result.AccessToken.TokenString, Configure.PN_ACCOUNT_FACEBOOK, (status, errorCode, jsonString, values) =>
{
if (status.Equals(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");
}
}
});
}
else
{
Debug.Log("Login Cancel");
}
}
}
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"
}
}
Communication Result 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
If no player information exists
ErrorCode : 30000
ErrorMessage : NotFoundAccountException
If player information is being used on another device
ErrorCode : 30006
ErrorMessage : DuplicatedDeviceException
If a player has requested withdrawal
ErrorCode : 30007
ErrorMessage : WithDrawalException