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.
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.
Field | Description | Remark |
---|---|---|
WEBVIEW_FULLSCREEN_ENABLE | Whether to display in full screen mode Default value: Disable | Optional |
WEBVIEW_PORTRAIT_HIDEBAR_ENABLE | Whether to hide the menu bar in portrait mode Default value: 0: Don't Hide | Optional |
WEBVIEW_LANDSCAPE_HIDEBAR_ENABLE | Whether to hide the menu bar in landscape mode Default value: 0: Don't Hide | Optional |
WEBVIEW_SHARE_CHANNEL | JS 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_FILTER | Filters 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_DISABLE | Disables Back button (Android only) Default value: 0: Don't disable | Optional |
WEBVIEW_DEFAULT_WIDTH | Windows Login WebView width Units: % | Required for Windows |
WEBVIEW_DEFAULT_HEIGHT | Windows Login WebView height Units: % | Required for Windows |
WEBVIEW_NAVIGATION_BUTTON_DISABLE | Whether to disable the back and system browser button, Windows platforms only Default: 0, not disabled | Required for Windows |
WEBVIEW_UI_COLOR_THEME | WebView framework style (dark/light), Windows platform only Default: Dark | Required for Windows |
WEBVIEW_VIEWPORT_DPI | Webview dots per inch, sets length and width of the browser, Windows platform only Default: 96 | Required for Windows |
WEBVIEW_ALWAYS_ON_TOPMOST_WINDOW | Sets WebView to be always in front, Windows platform only Default: 0, not always in front | Optional for Windows |
WEBVIEW_ACCEPTED_LANGUAGE_LIST | Provides 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_DISABLE | Disable 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
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
: SettargetSdkVersion
to less than 26. If the Android system sets thetargetSdkVersion
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 thetargetSdkVersion
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 thetargetSdkVersion
to 26 or above: Disable the default HTTP interception in thenetworkSecurityConfig
file (setcleartextTrafficPermitted="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
- Unity
- Unreal Engine
API | Function |
---|---|
AddWebViewResultObserver | Registers the WebViewResult callback of the Player Network SDK WebView module. Use it to manage OpenUrl interface callback. |
RemoveWebViewResultObserver | Unregisters WebViewResult callback. |
API | Function |
---|---|
SetWebViewResultObserver | Sets WebViewResult callback for the Player Network SDK WebView module. |
GetWebViewResultObserver | Gets WebViewResult callback. |
OnWebViewResult_Implementation | Implements WebViewResult callbacks for interfaces such as OpenUrl. |
WebView functions
- Unity
- Unreal Engine
API | Function |
---|---|
OpenUrl | Opens a URL |
GetEncryptUrl | Returns encrpyted version of input URL |
CallJS | Calls JS code from native |
API | Function |
---|---|
OpenUrl | Opens a URL |
GetEncryptUrl | Returns encrpyted version of input URL |
CallJS | Calls JS code from native |