This repository shows a basic proof of concept for running Microblink's Browser SDKs in a WebChromeClient so that it:
- Requests adequate permissions from the user in the native layer
- Loads the designated URL which should host one of Microblink's Browser SDKs
- Ensures permission requests from the browser are appropriately handled by the native layer
To deploy the sample application, simply clone the repository, update the webView.loadUrl and deploy it on your physical Android device.
The most important thing to note is that one has to request the proper permissions (in AndroidManifest.xml file):
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
Then, along with the usual permission handling on the Android level (see here), the same permissions requests need to be handled within the Webview object (code in MainActivity.kt):
if (request.resources.contains(PermissionRequest.RESOURCE_VIDEO_CAPTURE) ||
request.resources.contains(PermissionRequest.RESOURCE_AUDIO_CAPTURE) ) {
request.grant(request.resources)
}
By ensuring the necessary permissions are incorporated into the Android Manifest and browser permission requests are appropriately replied by the native layer, Microblink's Browser SDKs can be easily accessed in a WebView context.
Hope this helps, and if you'll have any additional questions, please reach out to us and we'll be happy to help.