Embedded Android

Android requires runtime permissions to be set accurately for embedded views to accommodate location and camera access.

Since WorkBright runs in a WebView, not only do Android permissions have to be handled, but you must “forward” the access to WebViews as well. This is done through a class called WebChromeClient/WebViewClient.

Camera:

  • The WebView invokes a callback called onPermissionRequest(request: PermissionRequest?), which contains a constant for android.webkit.resource.VIDEO_CAPTURE that resolves to a camera request.
  • The default implementation is request.deny(), it must be overridden in order to ensure Android-level permissions are granted. It must also be manually grant to the WebView as well.

Location:

  • onGeolocationPermissionsShowPrompt(origin: String?, callback: GeolocationPermissions.Callback?) is called by the WebView.
  • The original implementation is empty, so a request will never show. You must override this so that you ensure Android-level permissions are granted, then call the callback that you are now ready to provide geolocation to the WebView.