Skip to main content

WebView

The WebView function allows opening a specific webpage within the game using either Player Network SDK's WebView component or the native system browser. It is available for Android, iOS, and PC platforms. The WebView interface passes the OpenID and token to the server, connecting the Player Network account service with the opened webpage. As such, the WebView can be utilized for launching web-based questionnaires, marketing campaign webpages, and HTML5 player communities within the game.

The WebView interface is implemented using the system WebView component, and it can call native functions from JS or call JS functions from native code.

note

For information on JS and native interaction, see INTLWebViewSample.html.

WebView configurations

Before using the WebView interface, install the SDK and configure the WebView module in the INTLConfig.ini file according to the following information.

FieldDescriptionRemark
WEBVIEW_FULLSCREEN_ENABLEWhether to display in full screen mode
Default value: Disable
Optional
WEBVIEW_PORTRAIT_HIDEBAR_ENABLEWhether to hide the menu bar in portrait mode
Default value: 0: Don't Hide
Optional
WEBVIEW_LANDSCAPE_HIDEBAR_ENABLEWhether to hide the menu bar in landscape mode
Default value: 0: Don't Hide
Optional
WEBVIEW_SHARE_CHANNELJS sharing channels, supporting Facebook, LINE, and System
When this field is set to NONE, no share buttons are displayed.
When this field is set to any channels, browser share will be enabled as well.
Default value: Facebook,Line,System
Optional
WEBVIEW_URL_KEY_FILTERFilters URLs for relevant login state keywords
Use commas (,) to separate fields, such as: accesstoken,username
If filtering is not required, input NONE
Windows platform is currently not supported.
Set isSameProcessWebView=true for the ExtraJson parameter in OpenURL method on the Android platform.
Optional
CONFIG_KEY_BACK_DISABLEDisables Back button (Android only)
Default value: 0: Don't disable
Optional
WEBVIEW_DEFAULT_WIDTHWindows Login WebView width
Units: %
Required for Windows
WEBVIEW_DEFAULT_HEIGHTWindows Login WebView height
Units: %
Required for Windows
WEBVIEW_NAVIGATION_BUTTON_DISABLEWhether to disable the back and system browser button, Windows platforms only
Default: 0, not disabled
Required for Windows
WEBVIEW_UI_COLOR_THEMEWebView framework style (dark/light), Windows platform only
Default: Dark
Required for Windows
WEBVIEW_VIEWPORT_DPIWebview dots per inch, sets length and width of the browser, Windows platform only
Default: 96
Required for Windows
WEBVIEW_ALWAYS_ON_TOPMOST_WINDOWSets WebView to be always in front, Windows platform only
Default: 0, not always in front
Optional for Windows
WEBVIEW_ACCEPTED_LANGUAGE_LISTProvides WebView accepted language list, Windows platform only
For more information on language settings, see ISO Language Code Table.
Default: en-US,zh-CN,ja-JP,ko-KR
Optional for Windows
WEBVIEW_SHARE_BUTTON_DISABLEDisable share(Open URL in system browser) button
Default: 0, Enable share button;
1 - Disable share button, 0 - Enable share button
Configure for Windows Platform Only

Open HTTP web page via Android Webview

caution

For security concerns, Android officially and strongly recommends using the HTTPS protocol instead of the HTTP protocol. It is safer to use WebView to load HTTPS web pages on Android devices.

To load HTTP, use the following solutions:

  • A. Do not use android:networkSecurityConfig: This tag is used to specify an XML file for network security configuration. Without this configuration, both HTTP and HTTPS can be opened without any restrictions. The disadvantage of this solution is that it may lead users to load into insecure webpages.

  • B. Load the HTTP webpage while using android:networkSecurityConfig: Set targetSdkVersion to less than 26. If the Android system sets the targetSdkVersion to less than 26, the loading of HTTP web pages will not be restricted. The disadvantage of this solution is that there are corresponding restrictions on the implementation of the app and its release on Google Play.

  • C. Use the android:networkSecurityConfig while setting the targetSdkVersion to 26 or above: Set the HTTP access permission list to bypass the restriction of the Android system on access to HTTP web pages. The disadvantage of this solution is that if a webpage's domain name is added to the permission list, the app needs to be released again.

  • D. Use the android:networkSecurityConfig while setting the targetSdkVersion to 26 or above: Disable the default HTTP interception in the networkSecurityConfig file (set cleartextTrafficPermitted="true" in the base-config node) or delete the entire node. The effect of this solution is the same as that of solution A, but the disadvantage is that it may lead users to load into unsafe webpages. The specific code is as follows:

    <base-config cleartextTrafficPermitted="true">
    <trust-anchors>
    <certificates src="system"/>
    </trust-anchors>
    </base-config>

To implement any of the above solutions, set android:usesClearTextTraffic="true" in the AndroidManifest.xml file.

Callbacks

APIFunction
AddWebViewResultObserverRegisters the WebViewResult callback of the Player Network SDK WebView module. Use it to manage OpenUrl interface callback.
RemoveWebViewResultObserverUnregisters WebViewResult callback.

WebView functions

APIFunction
OpenUrlOpens a URL
GetEncryptUrlReturns encrpyted version of input URL
CallJSCalls JS code from native