Customer module callback (CustomerResultObserver)
Register the Player Network SDK customer module callback to receive customer service operation notifications. Currently, the callback is triggered only when the customer service UI is closed or when an account is deleted.For more information about the callback data structure, see CustomerResult.For more information about the WebView callback, see WebViewResultObserver.
note
It is strongly recommended that games register during the application start-up function.
Function definition
// Add INTLCustomerResult callback
public static void AddCustomerResultObserver(OnINTLResultHandler<INTLCustomerResult> callback);
// Remove INTLCustomerResult callback
public static void RemoveCustomerResultObserver(OnINTLResultHandler<INTLCustomerResult> callback);
Code sample
// Add callback
public void AddCustomerObserver()
{
INTLAPI.AddCustomerResultObserver(OnCustomerResultEvent);
INTLAPI.AddWebViewResultObserver(OnWebViewRetEvent);
}
// Remove callback
public void RemoveCustomerObserver()
{
INTLAPI.RemoveCustomerResultObserver(OnCustomerResultEvent);
INTLAPI.RemoveWebViewResultObserver(OnWebViewRetEvent);
}
// Callback handler for INTLCustomerResult
public void OnCustomerResultEvent(INTLCustomerResult ret)
{
Debug.Log($"MethodID: {ret.MethodId}");
string methodTag = "";
if (ret.MethodId == (int)INTLMethodID.INTL_CUSTOMER_INIT)
{
methodTag = "InitCustomer";
}
if (ret.MsgType == 100) // 100 means closing the interface
{
m_sample.ShowLogInNewLine(methodTag + ": close Customer Service UI.");
}
else
{
m_sample.ShowLogInNewLine("MsgType: " + ret.MsgType.ToString());
}
}
// Callback handler for deleting account in INTLWebViewResult
private void OnWebViewRetEvent(INTLWebViewResult webViewRet)
{
#if INTL_OS_WINDOWS
#else
if (webViewRet.MethodId == (int) INTLMethodID.INTL_WEBVIEW_JS_CALL)
{
// This is a non-unity process, make sure not to perform unity-related operations
INTLLog.Log("before AddMessage in customer");
CustomerSample.AddMessage("WebViewRetEvent: " + Tools.Instance.GetRetString(webViewRet));
}
else
{
m_sample.ShowLogInNewLine("WebViewRetEvent: " + Tools.Instance.GetRetString(webViewRet));
}
#endif
}