Skip to main content

Mobile WebView

WebView Configuration

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

FieldDescriptionNote
WEBVIEW_FULLSCREEN_ENABLEFullscreen or not
Default: Off
Optional
WEBVIEW_PORTRAIT_HIDEBAR_ENABLEHide menu bar in portrait mode
Default: 0, not hidden
Optional
WEBVIEW_LANDSCAPE_HIDEBAR_ENABLEHide menu bar in landscape mode
Default: 0, not hidden
Optional
WEBVIEW_SHARE_CHANNELJS share channels, supports Facebook, LINE, System
When set to NONE, the share button is hidden
When any value is set to this field, system sharing is enabled.
Default: Facebook, Line, System.
Optional
WEBVIEW_URL_KEY_FILTERFilter URLs with keywords related to login status
Separate fields with commas (,), e.g.: accesstoken,username
If you do not need to filter, enter NONE
Not supported on Windows platform at present.
Set isSameProcessWebView=true in the ExtraJson parameter for OpenURL on the Android platform.
Optional
CONFIG_KEY_BACK_DISABLEDisable the back button (Android only)
Default: 0, not disabled
Optional

Android WebView Gradle Configuration

caution

WEBVIEW_TASK_AFFINITY configuration has been deprecated since Player Network SDK V1.25:

  • Before SDK V1.25, WebView was opened in a new process by default.
  • From SDK V1.25 onwards, WebView is opened in the current process by default.
android {
defaultConfig {
manifestPlaceholders = ['WEBVIEW_TASK_AFFINITY':'${applicationId}']
}
}

By configuring WEBVIEW_TASK_AFFINITY, you can set the taskAffinity of the WebView activity. The default value for WEBVIEW_TASK_AFFINITY is application ID.

  • If you need WebView and the main activity in the same task stack, and the application ID and package name are different, set WEBVIEW_TASK_AFFINITY to the package name.
  • If you need to open WebView in a new task stack, you can set 'WEBVIEW_TASK_AFFINITY':''.

Android WebView opening HTTP webpages

caution

For security reasons, Android officially strongly recommends using HTTPS instead of HTTP.It is more secure to use WebView to load HTTPS pages on the Android system.

If you must load HTTP, you can 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, any HTTP and HTTPS page can be opened without any restriction.The downside of this solution is that it may load insecure webpages.

  • B. Use android:networkSecurityConfig and load HTTP pages: set targetSdkVersion below 26 (excluding 26).If the Android system sets targetSdkVersion below 26, loading HTTP pages is not restricted.The downside of this solution is that app implementation and publishing on Google Play will have corresponding restrictions.

  • C. Use android:networkSecurityConfig and set targetSdkVersion to 26 or above: set a whitelist for HTTP access to bypass Android''s restriction on accessing HTTP pages.The downside of this solution is that when new domain names are added to the whitelist, the app needs to be republished.

  • D. Use android:networkSecurityConfig and set targetSdkVersion to 26 or above: turn off the default HTTP restriction 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 solution A, and the downside is also that insecure webpages may be loaded.Specific code as follows:

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

All of the above solutions require setting android:usesClearTextTraffic="true" in the AndroidManifest.xml file.