Skip to main content

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.

AndroidiOSWindows
note

MSDK currently does not support Windows.

Function Definition

void OpenUrl(string url,
int screenOrientation = 1,
bool fullScreenEnable = false,
bool encryptEnable = true,
bool systemBrowserEnable = false,
string extraJson = "{}");

Input Parameters

ParameterTypeDescription
urlstringWebpage address
URLs with Chinese characters must go through url encode
screenOrientationintAuto=1
Portrait=2
Landscape=3
fullScreenEnableboolWhether to open in full screen mode
Default: false
encryptEnableboolWhether to add login state data to link
Default: true
When encryptEnable is true and user is logged in, the specified URL is encrypted
systemBrowserEnableboolWhether to open with the system browser
Default: false
extraJsonstringJSON format extended field, see MSDK document or Player Network Documentation.
Empty by default

Event Page Parameters

ParameterDescription
role_idRole ID
role_nameURL-encoded role name
area_idGame area ID
zone_idGame zone ID
lang_typeLanguage 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.

The callback event is WebViewRetEvents. The callback methodID is GUA_WEBVIEW_CLOSE_URL.

Code Sample

note

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.
//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}");

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.

GUA_NAMESPACE::GUAWebViewService::OpenUrl("https://www.qq.com", 1, false, true);
  • If not logged in and calling OpenURL with encryptEnable = true, the opened URL is:

    https://www.qq.com
  • If logged in and calling OpenURL with encryptEnable = 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

ParameterDescription
gameidAssigned game ID
channelidChannel ID of the login channel
osClient operating system
1: Android
2: iOS
3: Web
4: Linux
5: Windows
6: Switch
tsTimestamp
sdk_versionSDK Version
seqSequence ID
encodeparamAccount 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.