Skip to main content

GUAWebViewResultObserver

Register the callback of the Player Network SDK WebView module, the game needs to process the callback function. For more information on the callback data structure, see GUAWebViewRet.

note

[Player Network SDK & MSDK] 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]
WebViewRetEventsOpenUrl,
CallJS,
GetEncodeUrl
QueryDeviceLevelOpenGameDataAuthCenter,
OpenAmsCenter
event OnResultHandler<GUAWebViewRet> WebViewRetEvents;

Code Sample

// Add callbacks
UnionAdapterAPI.GetWebViewService().WebViewRetEvents += OnWebViewRetEvent;

// Remove callbacks
UnionAdapterAPI.GetWebViewService().WebViewRetEvents -= OnWebViewRetEvent;

// Process the WebViewRetEvents callback
private void OnWebViewRetEvent(GUAWebViewRet ret)
{
string methodTag = "";
if (ret.MethodId == (int)GUAMethodID.GUA_WEBVIEW_GET_ENCRYPT_URL) {
methodTag = "GetEncodeUrl";
}
else if (ret.MethodId == (int)GUAMethodID.GUA_WEBVIEW_JS_CALL)
{
methodTag = "JsCall";
UnionAdapterAPI.GetWebViewService().CallJS(WebViewSample.callJSParams);
}
else if (ret.MethodId == (int)GUAMethodID.GUA_WEBVIEW_JS_SHARE)
{
methodTag = "JsShare";
}
else if (ret.MethodId == (int)GUAMethodID.GUA_WEBVIEW_CLOSE_URL)
{
methodTag = "Close WebView";
}
else if (ret.MethodId == (int)GUAMethodID.GUA_WEBVIEW_JS_IS_APP_INSTALLED)
{
methodTag = "IsAppInstalled";
}
Debug.Log(methodTag + ret.ToString());
}