Native calls JS functions (CallJS)
[Player Network SDK & MSDK] Interface for interaction between native and web JS.
Supported Platforms
- Unity
- Unreal Engine
Supports
Android, iOS, Windows platform.Supports
Android, iOS, Windows platform.note
MSDK does not support Windows for now.
Function Definition
- Unity
- Unreal Engine
void CallJS(string jsonJsParam);
static void CallJS(const std::string &json_js_params);
Input Parameters
- Unity
- Unreal Engine
| Parameters | Type | Description |
|---|---|---|
| jsonJsParam | string | JSON format string |
| Parameters | Type | Description |
|---|---|---|
| json_js_params | std::string | JSON format string |
Callback Handling
The callback handling interface is GUAWebViewResultObserver.The callback data structure is GUAWebViewRet.
- Unity
- Unreal Engine
The callback event is WebViewRetEvents. Callback ID is GUA_WEBVIEW_JS_CALL.
The callback event is OnWebViewOptNotify. The callback ID is kMethodIDWebViewJsCall.
Code Example
- Unity
- Unreal Engine
UnionAdapterAPI.GetWebViewService().CallJS("jsonJsParam");
GUA_NAMESPACE::GUAWebViewService::CallJS("jsonJsParam");