Compatibility Configuration Guide for Using FaceID H5 in an App
- HTTPS is required;
- Configurations are required to use web-view in Android and iOS apps.
Android solution
For the native WebView in Android 5.0 or later, camera permissions are required in the app.
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
A pop-up window will appear on the webpage to request camera permissions. You need to handle the permission request and grant permissions in the WebView.
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onPermissionRequest(final PermissionRequest request) {
Log.d("MainActivity", "onPermissionRequest");
MainActivity.this.runOnUiThread(new Runnable() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void run() {
request.grant(request.getResources());
}
});
}
});
For browsers with other engines, set the configurations based on the requirements of the browser.
IOS solution
Only WKWebView in iOS supports WebRTC.
Objective-C:
// Initialize configuration object
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
// The default value is NO. This value indicates whether HTML5 videos play inline or use the native full-screen controller.
configuration.allowsInlineMediaPlayback = YES;
// The videos play automatically without a user gesture if
if (@available(iOS 10.0, *)) {
// WKAudiovisualMediaTypeNone No audio or video requires a user gesture to begin playing (audio or video plays automatically).
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
} else {
configuration.requiresUserActionForMediaPlayback = NO;
}
WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration];
Swift:
// Initialize configuration object
let configuration = WKWebViewConfiguration()
// The default value is NO. This value indicates whether HTML5 videos play inline or use the native full-screen controller.
configuration.allowsInlineMediaPlayback = true
// The videos play automatically without a user gesture.
if #available(iOS 10.0, *) {
// WKAudiovisualMediaTypeNone No audio or video requires a user gesture to begin playing (audio or video plays automatically).
configuration.mediaTypesRequiringUserActionForPlayback = []
} else {
configuration.requiresUserActionForMediaPlayback = false
}
let webView = WKWebView(frame: CGRect.zero, configuration: configuration)