Skip to main content

GUABaseResultObservers

[Shared by Player Network SDK & MSDK] Callback for the registration and login module. The game needs to handle this callback.For more details on the callback data structure, see the data structure GUABaseResult.

note

It is strongly recommended that the game registers the callback in the application startup function.

Function Definition

List of methods used to handle the callback

Callback eventCommon[Player Network SDK only][MSD only]
LoginBaseResultEventsLogout,
ResetGuest
ModifyLegalDocumentsAcceptedVersion,
Unbind,
CancelAccountDeletion
CheckUniversalLink,
ChannelPermissionAuth
event OnResultHandler<GUABaseResult> LoginBaseResultEvents;

Code Example

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

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

// Handling the callback of LoginBaseResultEvents
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) // [MSD 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 alternate accounts
/// </summary>
/// <param name="baseRet">Base ret.</param>
private void handleDiifAccount(GUABaseResult baseRet)
{
string methodTag = "WAKEUP";
switch (baseRet.RetCode)
{
case GUAErrorCode.SUCCESS:
{ // The existing 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:
{ // Old and new openid are the same, but the tickets are 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, pop up with a ticket, use the 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;
}
}