When integrating the ID Verification H5 mobile SDK into mobile applications (apps), compatibility issues may occur due to the embedded browser (WebView) version, built-in permissions, and other factors. This topic describes how to configure WebView in your app to use camera devices, enable web video playback, and manage other permissions to reduce compatibility issues with the H5 mobile SDK.
Android configuration
Due to the severe fragmentation of the Android ecosystem, using the Android native Webview in your app to access the system camera may cause compatibility issues, such as camera access being rejected or the facial verification page failing to launch after re-authorization.
Follow these steps to resolve compatibility issues:
Declare the following permissions in the
AndroidManifest.xmlfile:<!--Application camera access permission.--> <uses-permission android:name="android.permission.CAMERA" /> <!--Application network access permission.--> <uses-permission android:name="android.permission.INTERNET" />Configure WebView:
Override the
onPermissionRequest()method to enable the callback for the web page's permission prompt.For WebView-based web applications, permission management is handled by the browser. When a user on an H5 page attempts to access the camera, if they deny the permission request, any subsequent attempts to access the camera on that page will be denied by default.
Therefore, you can override the
onPermissionRequest()method to customize the handling of webpage permission requests. See the following example:webView.setWebChromeClient(new WebChromeClient(){ @Override public void onPermissionRequest(PremissionRequest request) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Check if the current device system version is Android 5.0 or later. // If so, directly grant all permissions requested by the webpage. This example is for reference only. Rewrite according to your actual situation. request.grant(request.getResources()); } } });Configure WebView to allow automatic video playback on webpages:
// Allow autoplay. webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
iOS configuration
In the
Info.plistfile, declare theNSCameraUsageDescriptionkey, and provide a clear description to inform users why the application needs to access camera permissions. For example:<key>NSCameraUsageDescription</key> <string>We need to access your camera to take photos or scan QR codes.</string>Configure the WKWebViewConfiguration of WebView, and set it to allow automatic video playback and in-page playback:
Swift
// Configure camera usage through WKWebViewConfiguration class. let config = WKWebViewConfiguration() config.allowsPictureInPictureMediaPlayback = true // Allow automatic video playback. let myAudiovisualMediaType: WKAudiovisualMediaTypes = [] config.mediaTypesRequiringUserActionForPlayback = myAudiovisualMediaType // Allow video playback within the webpage (non-full screen playback). config.allowsInlineMediaPlayback = trueObjective-C
// Configure camera usage through WKWebViewConfiguration class. WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init]; config.allowsInlineMediaPlayback = YES; // Allow automatic video playback. config.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; // Allow video playback within the webpage (non-full screen playback). config.allowsInlineMediaPlayback = YES;
WebRTC compatibility support list
In iOS 14.3 and later versions, WKWebView added support for WebRTC.
Therefore, WeChat, third-party browsers, and apps need to run on iOS 14.3 and later versions to support WebRTC functionality.
For third-party iOS apps that do not use WKWebView, you need to check whether the WebView being used supports WebRTC functionality to determine if it supports WebRTC.
Client | Android version | iOS version |
Edge | Android 4.0 and later | iOS 14.3 and later |
FireFox | ||
Chrome | ||
Opera | ||
Baidu | ||
Android Browser 5.0+ | ||
Safari | No supported | iOS 11 and later |
UC | Android 4.0 and later | No supported |
UC Browser Turbo | ||
Manufacturer-embedded browsers | Supported on some models such as Xiaomi and Samsung | |
WeChat (App) | Android 4.0 and later | iOS 14.3 and later |
App | Android 4.0 and later with WebView that supports WebRTC | iOS 14.3 and later using iOS built-in WKWebView |