ComplianceResultObserver
Registers the callback of the Player Network SDK compliance module, the game needs to process the callback function. For more information on the callback data structure, see ComplianceResult.
note
It is strongly recommended to perform registration in the startup function of the game application.
Function definition
// Add the INTLComplianceResult callback to process callback
public static void AddComplianceResultObserver(OnINTLResultHandler<INTLComplianceResult> callback);
// Remove the INTLComplianceResult callback
public static void RemoveComplianceResultObserver(OnINTLResultHandler<INTLComplianceResult> callback);
Code sample
// Add callbacks
public void AddComplianceObserver()
{
INTLAPI.AddComplianceResultObserver(OnComplianceResultEvent);
}
// Remove callbacks
public void RemoveComplianceObserver()
{
INTLAPI.RemoveComplianceResultObserver(OnComplianceResultEvent);
}
// Process the INTLComplianceResult callback
public void OnComplianceResultEvent(INTLComplianceResult complianceRet)
{
string methodTag = "";
string content = "";
if (complianceRet.MethodId == (int)INTLMethodID.INTL_COMPLIANCE_SET_USER_PROFILE)
{
methodTag = "SetUserProfile";
}
else if (complianceRet.MethodId == (int)INTLMethodID.INTL_COMPLIANCE_QUERY_USER_STATUS) // 1. Query user information
{
handleQueryUserInfo(complianceRet);
}
else if (complianceRet.MethodId == (int)INTLMethodID.INTL_COMPLIANCE_SET_ADULTHOOD) // 2. Set adult status
{
methodTag = "SetAdulthood";
content = complianceRet.RetCode == INTLErrorCode.SUCCESS ? "Set adult status successfully" : "Failed to set adult status";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
}
else if (complianceRet.MethodId == (int)INTLMethodID.INTL_COMPLIANCE_SET_EU_AGREE_STATUS) // 3. Set EU agreement
{
methodTag = "SetEUAgreeStatus";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
}
else if (complianceRet.MethodId == (int)INTLMethodID.INTL_COMPLIANCE_SEND_EMAIL) // 4. Send email
{
methodTag = "SendEmail";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
}
else if (complianceRet.MethodId == (int)INTLMethodID.INTL_COMPLIANCE_COMMIT_BIRTHDAY) // 5. Submit birthday
{
handleCommitBirthday(complianceRet);
}
else if (complianceRet.MethodId == (int)INTLMethodID.INTL_COMPLIANCE_VERIFY_CREDIT_CARD) // 6. Credit card authentication
{
methodTag = "VerifyCreditCard";
if (complianceRet.ParentCertificateStatus == 1)
{
content = "Credit card verification passed, you can enter the game";
}
if (complianceRet.ParentCertificateStatus == 11)
{
content = "Credit card verification status failed";
}
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
}
else if (complianceRet.MethodId == (int)INTLMethodID.INTL_COMPLIANCE_QUERY_EEA) //7. Whether it is EEA Region
{
methodTag = "QueryIsEEA";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine("Is it an EEA country :" + complianceRet.IsEEA);
}
}
private void handleQueryUserInfo(INTLComplianceResult complianceRet)
{
string methodTag = "QueryUserStatus";
string content = "";
if (complianceRet.RetCode != INTLErrorCode.SUCCESS)
{
content = "Request error";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
if (complianceRet.AdultStatus == 1)
{
content = "User is adult, can proceed directly to game";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
if (complianceRet.CertificateType == 0)
{
content = "No verification required, can proceed directly to game";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
if (complianceRet.AdultStatus == 0)
{
content = "Unknown player adult status, game must obtain the player's birth month and year and call CommitBirthday to submit user age information";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
//Start minor logic
switch (complianceRet.ParentCertificateStatus)
{
case -1: // Guardian verification refused
{
int current_ts = 0;
Int32.TryParse(complianceRet.TS, out current_ts);
int status_expiration = 0;
Int32.TryParse(complianceRet.ParentCertificateStatusExpiration, out status_expiration);
int time_left = status_expiration - current_ts;
int days = (int)time_left / (3600 * 24);
time_left = time_left % (3600 * 24);
int hours = (int)time_left / 3600;
time_left = time_left % 3600;
int mins = (int)time_left / 60;
content = "Minor user failed guardian verification, re-verification is allowed for your account in " + days + "d" + hours + "h" + mins + "m";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
break;
}
case 0: // No verification
{
content = "Minor player without verification, game must obtain player's birth month and year and call CommitBirthday to submit user age information";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
break;
}
case 1: // Guardian verification successful
{
int current_ts = 0;
Int32.TryParse(complianceRet.TS, out current_ts);
int status_expiration = 0;
Int32.TryParse(complianceRet.AdultStatusExpiration, out status_expiration);
if (status_expiration <= current_ts)
{
content = "Verification more than E days ago, display pop-up to ask if the player is an adult.If the user reports that he or she is an adult, call SetAdulthood(kAgeStautsAdult); If not, directly proceed to game";
}
else
{
content = "Verification less than E days ago, proceed directly to game";
}
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
case 10:
{
content = "Verification in progress, only for email verification.Pop up the email input window to resend email";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
default:
{
content = "Illegal status; this should not occur, check the log";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
break;
}
}
}
private void handleCommitBirthday(INTLComplianceResult complianceRet)
{
string methodTag = "CommitBirthday";
string content = "";
if (complianceRet.RetCode != INTLErrorCode.SUCCESS)
{
content = "Request error";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
if (complianceRet.AdultStatus == 1)
{
content = "User is adult, proceed directly to game";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
if (complianceRet.AdultStatus == -2)
{
content = "User age below minimum age of game rating, cannot access game";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
if (complianceRet.AdultStatus == 0)
{
content = "Adult status position.This status should not occur, check the log and feedback";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
if (complianceRet.ParentCertificateStatus == 1)
{
content = "Credit card verification successful, game access permitted";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
if (complianceRet.ParentCertificateStatus == 11)
{
content = "Credit card verification failed";
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
return;
}
//Minor, but verification is required
if (complianceRet.CertificateType == 0)
{
content = "Proceed directly to game without verification (default method)";
}
else if (complianceRet.CertificateType == 1)
{
content = "Self-verification (this method is not currently available)";
}
else if (complianceRet.CertificateType == 2)
{
content = "Credit card verification, Player Network SDK automatically implements the Midas logic";
}
else if (complianceRet.CertificateType == 3)
{
content = "Email verification, pop up email input window and call the SendEmail interface";
}
m_sample.ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(complianceRet));
m_sample.ShowLogInNewLine(content);
}