Skip to main content

GUABaseResultObservers

[MSDK and Player Network SDK] Registers the callback of the Auth module, the game needs to process the callback function. For more information on the callback data structure, see GUABaseResult.

note

It is strongly recommended to perform registration in the startup function of the game application.

Function Definition

The list of methods used to process the callback events.

Callback EventCommon[Player Network SDK Only][MSDK Only]
LoginBaseResultEventsLogout,
ResetGuest
ModifyLegalDocumentsAcceptedVersion,
Unlink,
CancelAccountDeletion
CheckUniversalLink,
ChannelPermissionAuth
event OnResultHandler<GUABaseResult> LoginBaseResultEvents;

Code Sample

// Add callbacks
UnionAdapterAPI.GetAccountService().LoginBaseResultEvents += OnLoginBaseResultEvent;

// Remove callbacks
UnionAdapterAPI.GetAccountService().LoginBaseResultEvents -= OnLoginBaseResultEvent;

// LoginBaseResultEvents callback
public void OnLoginBaseResultEvent(GUABaseResult baseRet)
{
Debug.Log("OnLoginBaseResultEvent in Login");
string methodTag = "";
if (baseRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_LOGOUT)
{
methodTag = "Logout";
}
else if (baseRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_WAKEUP) // [MSDK Only]
{
handleDiifAccount(baseRet);
}
else if (baseRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_UNBIND) // [Player Network SDK Only]
{
methodTag = "Unbind";
}
else if (baseRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_MODIFY_LEGAL_DOCUMENTS) // [Player Network SDK Only]
{
methodTag = "ModifyLegalDocument";
}
Debug.Log(methodTag + baseRet);
}

/// <summary>
/// Handle abnormal account
/// </summary>
/// <param name="baseRet">Base ret.</param>
private void handleDiifAccount(GUABaseResult baseRet)
{
string methodTag = "WAKEUP";
switch (baseRet.RetCode)
{
case GUAErrorCode.SUCCESS:
{ // The original local ticket is valid, use the original ticket to log in

Debug.Log(methodTag + "Use the original ticket to log in, the game does not need to be processed");
break;
}
case GUAErrorCode.LOGIN_ACCOUNT_REFRESH:
{ // The old and new openid is the same, but the ticket is different. Refresh the login ticket

Debug.Log(methodTag + "The old and new openid is the same, but the ticket is different. Refresh the login ticket, the game does not need to process");
break;
}
case GUAErrorCode.LOGIN_URL_USER_LOGIN:
{// No local openid, use a new ticket to log in

Debug.Log(methodTag + "The old and new openid is the same, but the ticket is different. Refresh the login ticket, the game does not need to process");
break;
}
case GUAErrorCode.LOGIN_NEED_SELECT_ACCOUNT:
{
Debug.Log(methodTag + "Need select account")
break;
}
case GUAErrorCode.LOGIN_NEED_LOGIN:
{
Debug.Log(methodTag + "Tickets are invalid, enter the login page");
}
break;
default:
break;
}
}