Skip to main content

Callback for Self-built Account Module (AuthAccountResultObserver)

If you are using Unreal Engine, see Unreal Engine SDK's AuthAccountResultObserver.

Register the callback for the Player Network SDK's self-built account module; the game needs to handle the callback accordingly.For more information about callback data structure, see AccountResult.

note

It is strongly recommended that games register during the application start-up function.

Function definition

// Add INTLAccountResult callback for handling account callbacks
public static void AddAccountResultObserver(OnINTLResultHandler<INTLAccountResult> callback);

// Remove INTLAccountResult callback
public static void RemoveAccountResultObserver(OnINTLResultHandler<INTLAccountResult> callback);

Code sample

// Add callback
public void AddAuthObserver()
{
INTLAPI.AddAccountResultObserver(OnAuthAccountResultEvent);
}

// Remove callback
public void RemoveAuthObserver()
{
INTLAPI.RemoveAccountResultObserver(OnAuthAccountResultEvent);
}

// Account result callback handling
public void OnAuthAccountResultEvent(INTLAccountResult ret)
{
Debug.Log($"MethodID: {ret.MethodId}");

Debug.Log("OnAuthAccountResultEvent in Login");
string methodTag = "";
if (accountRet.MethodId == (int)INTLMethodID.INTL_AUTH_REQUEST_VERIFY_CODE)
{
methodTag = "RequestVerifyCode";
}
else if (accountRet.MethodId == (int)INTLMethodID.INTL_AUTH_RESET_PASSWORD)
{
// Corresponding to ResetPasswordWithVerifyCode, ResetPasswordWithOldPassword
methodTag = "ResetPassword";
}
else if (accountRet.MethodId == (int)INTLMethodID.INTL_AUTH_MODIFY_ACCOUNT)
{
// Corresponding to ModifyAccountWithVerifyCode, ModifyAccountWithPassword, ModifyAccountWithLoginState
methodTag = "ModifyAccount";
}
else if (accountRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_REGISTER_STATUS)
{
methodTag = "QueryRegisterStatus";
}
else if (accountRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_VERIFY_CODE_STATUS)
{
methodTag = "QueryVerifyCodeStatus";
}
else if (accountRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_IS_RECEIVE_EMAIL)
{
methodTag = "QueryIsReceiveEmail";
}
else if (accountRet.MethodId == (int)INTLMethodID.INTL_AUTH_REGISTER)
{
methodTag = "Register";
}
else if (accountRet.MethodId == (int)INTLMethodID.INTL_AUTH_MODIFY_PROFILE)
{
methodTag = "ModifyProfile";
}
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(accountRet));
}