Gamebase SDK for Unity 2.69.0
Toast Gamebase Platform
Loading...
Searching...
No Matches

◆ LoginForLastLoggedInProvider() [1/2]

static void LoginForLastLoggedInProvider ( Dictionary< string, object > additionalInfo,
GamebaseCallback::GamebaseDelegate< GamebaseResponse::Auth::AuthToken > callback )
static

Try login with the most recently logged-in IdP.

If a token is expired or its authentication fails, return failure. Note that a login for the IdP should be implemented.

Since
Added 2.54.0.
Parameters
additionalInfoThe additionalInfo which is additional information using for login.
callbackLogin result callback, returns the authentication token as a result of login.

Example Usage :

public void LoginForLastLoggedInProviderSample()
{
var additionalInfo = new Dictionary<string, object>
{
{ GamebaseAuthProviderCredential.SHOW_LOADING_ANIMATION, true } // Android only
};
Gamebase.LoginForLastLoggedInProvider(additionalInfo, (authToken, error) =>
{
if (Gamebase.IsSuccess(error) == true)
{
if(authToken.member.temporaryWithdrawal != null)
{
long gracePeriodDate = authToken.member.temporaryWithdrawal.gracePeriodDate;
Debug.Log(string.Format("User is under temporary withdrawa. GracePeriodDate : {0}", error));
} <br>
else
{
string userId = authToken.member.userId;
Debug.Log(string.Format("LoginForLastLoggedInProvider succeeded. Gamebase userId is {0}", userId));
}
}
else
{
if (error.code == GamebaseErrorCode.SOCKET_ERROR || error.code == GamebaseErrorCode.SOCKET_RESPONSE_TIMEOUT)
{
Debug.Log(string.Format("Retry LoginForLastLoggedInProvider or notify an error message to the user. : {0}", error.message));
}
else
{
if (string.IsNullOrEmpty(Gamebase.GetLastLoggedInProvider()) == true)
{
// Display the IdP select menu to user.
}
else
{
Gamebase.Login(Gamebase.GetLastLoggedInProvider(), (innerAuthToken, innerError) =>
{
if (Gamebase.IsSuccess(innerError) == true)
{
string userId = innerAuthToken.member.userId;
Debug.Log(string.Format("LoginForLastLoggedInProvider succeeded. Gamebase userId is {0}", userId));
}
else
{
// Check the error code and handle the error appropriately.
Debug.Log(string.Format("LoginForLastLoggedInProvider failed. error is {0}", innerError));
}
});
}
}
}
});
}