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.
| Field | Description | Note |
|---|---|---|
| WEBVIEW_FULLSCREEN_ENABLE | Fullscreen or not Default: Off | Optional |
| WEBVIEW_PORTRAIT_HIDEBAR_ENABLE | Hide menu bar in portrait mode Default: 0, not hidden | Optional |
| WEBVIEW_LANDSCAPE_HIDEBAR_ENABLE | Hide menu bar in landscape mode Default: 0, not hidden | Optional |
| WEBVIEW_SHARE_CHANNEL | JS share channels, supports Facebook, LINE, System When set to NONE, the share button is hiddenWhen any value is set to this field, system sharing is enabled. Default: Facebook, Line, System. | Optional |
| WEBVIEW_URL_KEY_FILTER | Filter URLs with keywords related to login status Separate fields with commas (,), e.g.: accesstoken,usernameIf you do not need to filter, enter NONENot supported on Windows platform at present. Set isSameProcessWebView=true in the ExtraJson parameter for OpenURL on the Android platform. | Optional |
| CONFIG_KEY_BACK_DISABLE | Disable the back button (Android only) Default: 0, not disabled | Optional |
Android WebView Gradle Configuration
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.
- Unity
- Unreal Engine
android {
defaultConfig {
manifestPlaceholders = ['WEBVIEW_TASK_AFFINITY':'${applicationId}']
}
}
对于 Player Network SDK V1.17 - V1.24.01,请编辑 INTLConfig_APL.xml。
For Player Network SDK V1.16.04 and earlier, please edit INTLCore_UPL.xml.
<buildGradleAdditions>
<insert>
<![CDATA[
android{
defaultConfig {
manifestPlaceholders = ['WEBVIEW_TASK_AFFINITY':'${applicationId}']
}
}]]>
</insert>
</buildGradleAdditions>
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_AFFINITYto 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
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:networkSecurityConfigand load HTTP pages: settargetSdkVersionbelow 26 (excluding 26).If the Android system setstargetSdkVersionbelow 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:networkSecurityConfigand settargetSdkVersionto 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:networkSecurityConfigand settargetSdkVersionto 26 or above: turn off the default HTTP restriction in thenetworkSecurityConfigfile (setcleartextTrafficPermitted="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.