Skip to content

An example application that uses WebChromeClient to load the BlinkID Browser SDK and validates the necessary permissions are granted.

Notifications You must be signed in to change notification settings

BlinkID/example-android-webview-blinkid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microblink Webview Sample

TL;DR

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.

Requirements

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)
    }

Conclusion

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.

About

An example application that uses WebChromeClient to load the BlinkID Browser SDK and validates the necessary permissions are granted.

Resources

Stars

Watchers

Forks

Languages