OpenUrl
If you were looking for the method for use with Unreal Engine, see OpenUrl for Unreal Engine SDK.
This API is used to open a specified webpage through the WebView module and control the WebView display based on different parameters.
Function definition
public static void OpenUrl(string url, INTLWebViewOrientation screenOrientation = INTLWebViewOrientation.Auto, bool fullScreenEnable = false,
bool encryptEnable = true, bool systemBrowserEnable = false, string extraJson = "{}")
Input parameters
Parameter | Type | Description |
---|---|---|
url | string | Webpage address URLs with Chinese characters must use url encode |
screenOrientation | INTLWebViewOrientation | Auto=1 Portrait=2 Landscape=3 |
fullScreenEnable | bool | Whether to open in full screen mode Default: false |
encryptEnable | bool | Adds 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 Empty by default |
Event page parameters
Name | 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. |
OpenUrl extended field configuration (Not supported in PS5 and XSX)
Android has already been adapted to notched displays by default, and no additional configuration is required.
Name | Type | Note |
---|---|---|
width | int | Windows WebView width Units: % |
height | int | Windows WebView height Units: % |
BG_COLOR | string | Sets the WebView background color For example: ff0000. |
PROGRESS_TYPE | int | Sets the progress bar type 0: Progress bar + Loading icon 1: Progress bar 2: Loading icon |
isSameProcessWebView | bool | Whether to start WebView in the same process Default: false |
CONFIG_KEY_BACK_DISABLE | bool | Whether to disable the back button Default: INTLConfig.ini configuration |
notch_full_screen | int | Whether the iPhone notch is covered 0: Not covered 1: Covered Default: 0 |
visibleShareMore | bool | Whether the share button is visible Default: true, which means visible |
Observers
The callback processing interface is WebViewResultObserver.
The callback data structure is WebviewResult.
The callback methodID is INTL_WEBVIEW_CLOSE_URL
.
Code sample
If the input URL cannot be opened, check that the URL is correct.
For example:
- Parameters cannot contain spaces
- For URLs with Chinese characters, users must perform url encode.
//Default effect: OpenUrl
INTLAPI.OpenUrl ("https://www.qq.com");
//OpenUrl and add login state data
INTLAPI.OpenUrl ("https://www.qq.com", INTLWebViewOrientation.Auto, false, true);
//Default effect: open event URL
INTLAPI.OpenUrl ("https://www.qq.com?role_id=1&role_name=aaa&area_id=1&zone_id=1&lang_type=en");
//OpenUrl and adjust Windows WebView width and height
INTLAPI.OpenUrl ("https://www.qq.com", INTLWebViewOrientation.Auto, false, true, false, "{\"height\": 60, \"width\": 80}");
Add Login State Data to Link
To automatically include parameters such as login state in the URL, set encryptEnable=true
when calling OpenUrl
after the user logs in.
In order to prevent information leakage, parameters such as the login state will be removed from the URL when being opened from a browser.
INTLAPI.OpenUrl ("https://www.qq.com", INTLWebViewOrientation.Auto, 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
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.