OpenUrl
If you were looking for the method for use with Unreal Engine, see OpenUrl for Unreal Engine SDK.
Starting from iOS 18, the openURL(_:) method in UIApplication
is no longer supported on iOS devices.
For SDK V1.26.00 and later, the method open(_:options:completionHandler:) is used instead, and is not affected.
For SDK V1.26.00 or earlier, INTLWebView
will be unable to redirect to the system browser Safari, and WebView H5 events in the game will also be unable to open webpages in Safari.
Affected projects are advised to update to SDK V1.26.00 and above as soon as possible.
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 information to URL
When calling OpenUrl
to open an URL while being logged in, encrypted login information is automatically included by default (encryptEnable=true
).
When opening an URL from a browser, parameters such as the login state will be removed from the URL to avoid information leakage.
INTLAPI.OpenUrl ("https://www.qq.com", INTLWebViewOrientation.Auto, false, true);
Calling
OpenUrl
withencryptEnable = true
when not logged in:https://www.qq.com
Calling
OpenUrl
withencryptEnable = true
while being logged in: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 | Player Network SDK Version |
seq | Sequence ID |
encodeparam | Encrypted account OpenID and token fields, obtained through the GetEncodeUrl API Can be decrypted using the Decrypted authentication backend API of Player Network SDK to obtain the corresponding parameters |
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.