OpenUrl
[Player Network SDK & MSDK] This API is used to open a specified webpage through the WebView module and controls the WebView display based on different parameters.
MSDK currently does not support Windows.
Function Definition
- Unity
- Unreal Engine
void OpenUrl(string url,
int screenOrientation = 1,
bool fullScreenEnable = false,
bool encryptEnable = true,
bool systemBrowserEnable = false,
string extraJson = "{}");
static void OpenUrl(
const std::string &url,
int screen_orientation = 1,
bool full_screen_enable = false,
bool encrypt_enable = true,
bool system_browser_enable = false,
const std::string &extra_json = "{}");
Input Parameters
- Unity
- Unreal Engine
Parameter | Type | Description |
---|---|---|
url | string | Webpage address URLs with Chinese characters must go through url encode |
screenOrientation | int | Auto=1 Portrait=2 Landscape=3 |
fullScreenEnable | bool | Whether to open in full screen mode Default: false |
encryptEnable | bool | Whether to add login state data to link Default: true When encryptEnable is true and user is logged in, the specified URL is encrypted |
systemBrowserEnable | bool | Whether to open with the system browser Default: false |
extraJson | string | JSON format extended field, see MSDK document or Player Network Documentation. Empty by default |
Parameter | Type | Description |
---|---|---|
url | std::string | Webpage address URLs with Chinese characters must go through url encode |
screen_orientation | int | Auto=1 Portrait=2 Landscape=3 |
full_screen_enable | bool | Whether to open in full screen mode Default: false |
encrypt_enable | bool | Whether to add login state data to link Default: true When encryptEnable is true and user is logged in, the specified URL is encrypted |
system_browser_enable | bool | Whether to open with the system browser Default: false |
extra_json | std::string | JSON format extended field, see MSDK document or Player Network Documentation. Empty by default |
Event Page Parameters
Parameter | Description |
---|---|
role_id | Role ID |
role_name | URL-encoded role name |
area_id | Game area ID |
zone_id | Game zone ID |
lang_type | Language type (RFC 4646) For example: "en". For details, see Language Type Definitions. |
Callback Processing
The callback processing API is GUAWebViewResultObserver. The callback data structure is GUAWebViewRet.
- Unity
- Unreal Engine
The callback event is WebViewRetEvents.
The callback methodID is GUA_WEBVIEW_CLOSE_URL
.
The callback event is OnWebViewOptNotify.
The callback methodID is kMethodIDWebViewURLClose
.
Code Sample
If the input URL cannot open, check that the URL is correct.
For example:
- Parameters cannot contain spaces.
- For URLs with Chinese characters, perform url encode.
- Unity
- Unreal Engine
//Open URL with default effect
UnionAdapterAPI.GetWebViewService().OpenUrl("https://www.qq.com");
//Open URL and add login state data
UnionAdapterAPI.GetWebViewService().OpenUrl("https://www.qq.com", 1, false, true);
//Open event URL with default effect
UnionAdapterAPI.GetWebViewService().OpenUrl("https://www.qq.com?role_id=1&role_name=aaa&area_id=1&zone_id=1&lang_type=en");
//Open URL and adjust Windows WebView width and height
UnionAdapterAPI.GetWebViewService().OpenUrl("https://www.qq.com", 1, false, true, false, "{\"height\": 60, \"width\": 80}");
//Open URL with default effect
GUA_NAMESPACE::GUAWebViewService::OpenUrl("https://www.qq.com");
//Open URL and add login state data
GUA_NAMESPACE::GUAWebViewService::OpenUrl("https://www.qq.com", 1, false, true);
//Open event URL with default effect
GUA_NAMESPACE::GUAWebViewService::OpenUrl("https://www.qq.com?role_id=1&role_name=aaa&area_id=1&zone_id=1&lang_type=en");
//Open URL and adjust Windows WebView width and height
GUA_NAMESPACE::GUAWebViewService::OpenUrl("https://www.qq.com", 1, false, true, false, "{\"height\": 60, \"width\": 80}");
Add Login State Data to Link
To have the URL automatically carry parameters such as login state, set encryptEnable=true
when calling OpenURL
after logging in.
- Unity
- Unreal Engine
GUA_NAMESPACE::GUAWebViewService::OpenUrl("https://www.qq.com", 1, false, true);
GUA_NAMESPACE::GUAWebViewService::OpenUrl("https://www.qq.com", 1, false, true);
If not logged in and calling
OpenURL
withencryptEnable = true
, the opened URL is:https://www.qq.com
If logged in and calling
OpenURL
withencryptEnable = true
, the opened URL is:https://www.qq.com?gameid=11&channelid=3&os=1&ts=1634707615&sdk_version=1.11.00.487&seq=11-3b61c8315b91d319eaa5622d72c474ec7ee395cee116d142a74b3455607e3d21-1634707615-14&encodeparam=C524E9DE27EB02E552CFBA9C54BFA301317DF66F49C5C02ED708D582B80A1B74DE8F0723731F0D66EBD12095E244097DC3AFAE1203A8FCD2A2821C1DEC9CD3AE254BAD99C93B095E8F39FCE414FBFB0A79F9EA8DF2E1B309190E5A8721A5AC8132E8E89506CDBA1ACBB1C17AA794A658502C5CCA6B25E6105049EABB44C408700FE2713FDD327217AF45A226F46FFD02
URL Parameters
Parameter | Description |
---|---|
gameid | Assigned game ID |
channelid | Channel ID of the login channel |
os | Client operating system 1: Android 2: iOS 3: Web 4: Linux 5: Windows 6: Switch |
ts | Timestamp |
sdk_version | SDK Version |
seq | Sequence ID |
encodeparam | Account OpenID and token encrypted fields Get the encrypted fields through the GetEncodeUrl API Get the corresponding parameter through MSDK Decryption API or Player Network SDK Decryption API. |
Open Event Page
To allow the event page to get in-game parameters and information, when the game uses WebView to open in-game events, the Url
must include the Event Page Parameters. For specific parameters, contact MSDK or the Player Network representative.