Skip to main content

Open webpage (OpenUrl)

[Player Network SDK & MSDK] Opening a web page is mainly done through the WebView module to display a specified web page, and the WebView display is controlled according to different parameters.

AndroidiOSWindows
note

MSDK does not currently support Windows.

Function Definition

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

Input Parameters

ParametersTypeDescription
urlstringWebpage address
Chinese in URL must be url encoded
screenOrientationintAuto = 1
Portrait = 2
Landscape = 3
fullScreenEnableboolWhether the webpage is opened in full screen
Default: false
encryptEnableboolAdd Login State Data to the Link
Default: true
If encryptEnable is true and the user is logged in, the specified URL will be encrypted
systemBrowserEnableboolWhether to open using the system browser
Default: false
extraJsonstringJSON format extended field, please see MSDK document or Player Network documentation.
Default is empty

Event Page Parameters

ParametersDescription
role_idRole ID
role_nameRole name URL-encoded
area_idRegion ID
zone_idZone ID
lang_typeLanguage type (RFC 4646)
For example, "en". For details, see Language Type Definition.

Callback Handling

The callback handling interface is GUAWebViewResultObserver.The callback data structure is GUAWebViewRet.

The callback event is WebViewRetEvents. The callback ID is GUA_WEBVIEW_CLOSE_URL.

Code Example

note

If the passed-in URL cannot be opened, please check if the provided URL is correct.

For example:

  • Parameters must not contain spaces
  • URLs containing Chinese must be url encoded
// Default effect to open URL
UnionAdapterAPI.GetWebViewService().OpenUrl("https://www.qq.com");

// Open URL and add login state data
UnionAdapterAPI.GetWebViewService().OpenUrl("https://www.qq.com", 1, false, true);

// Default effect to open event URL
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 the width and height of Windows WebView
UnionAdapterAPI.GetWebViewService().OpenUrl("https://www.qq.com", 1, false, true, false, "{\"height\": 60, \"width\": 80}");

Adding login data to links

If you want the link to automatically include login state and other parameters, the user must be logged in and call OpenURL with encryptEnable=true.

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

    https://www.qq.com
  • If the user is not logged in and OpenURL is called with encryptEnable = true, the opened link will be:

    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

ParametersDescription
gameidID assigned to the game
channelidLogin channel ID
OSTerminal operating system identifier
1 : Android
2 : iOS
3 : Web
4 : Linux
5 : Windows
6 : Switch
tsTimestamp
sdk_versionMSDK or Player Network SDK version
seqSequence number
encodeparamEncrypted fields for account OpenID and token
Obtained via the [GetEncodeUrl interface(/docs/resources/api/UnionAdapter/WebViewService/GUAGetEncodeUrl)
Decrypted and verified through backend APIs of MSDK or [Player Network SDK(/docs/resources/api/Backend/Auth/decrypt_aes#interface) to get the corresponding parameters.

Open Event Page

To allow the event page to access in-game parameter information, when the game opens an in-game event through WebView, the Url needs to include the Event Page Parameters. For specific parameters, please contact MSDK or Player Network support.