Web View Implementation

Configure your mobile app's WebView to support Medallion identity verification on iOS and Android.

Overview

Medallion uses the device camera to capture identity documents. When your mobile app opens a Medallion link in an embedded WebView, the WebView must grant the Medallion page access to the camera and must play the camera feed inline. iOS and Android disable one or more of these capabilities by default, so you must enable them explicitly on each platform your app supports.

This guide describes the required configuration for iOS (WKWebView) and Android (WebView). If your app is built with a cross-platform framework, also refer to Cross-platform frameworks.

🚧

Important: inline media playback is required on iPhone

If inline media playback is not enabled, iOS plays the camera feed in its full-screen video player. The document frame and on-screen guidance are hidden, and the user cannot complete ID capture. WKWebView disables inline media playback on iPhone by default.

Apply all WebView settings when the WebView is created. Changes made after creation have no effect.

Requirements at a glance

These requirements apply to every app, whether it is built natively or with a cross-platform framework such as React Native or Flutter, because all of them render web content in WKWebView on iOS and WebView on Android. Setting names are the native API names from the Apple and Android developer documentation. Cross-platform WebView libraries may use different names, and some apply certain settings automatically.

RequirementiOS (WKWebView)Android (WebView)
Camera usage declarationRequired. Add NSCameraUsageDescription to Info.plist.Required. Add android.permission.CAMERA to AndroidManifest.xml.
App camera permissionAutomatic. The system prompts the user the first time the page accesses the camera.Required. Request the permission at runtime before opening the Medallion link.
Page camera accessNot required. Granting it prevents a second camera prompt on iOS 15 and later (requestMediaCapturePermissionFor).Required. Grant the page's camera request in onPermissionRequest.
Inline playbackRequired. Set allowsInlineMediaPlayback to true.Not applicable.
Playback without user interactionRequired. Set mediaTypesRequiringUserActionForPlayback to an empty set.Required. Set mediaPlaybackRequiresUserGesture to false.
JavaScript and DOM storageAutomatic. Enabled by default.Required. Set javaScriptEnabled and domStorageEnabled to true.

iOS configuration

Step 1: Declare camera usage

Add the NSCameraUsageDescription key to your app's Info.plist, with a message that explains why your app requires access to the camera.

Step 2: Configure the WebView

Apply the following settings to the WKWebViewConfiguration before you create the WKWebView. The WebView copies its configuration at creation, so later changes have no effect.

  • Set allowsInlineMediaPlayback to true so that the camera feed plays within the page.
  • Set mediaTypesRequiringUserActionForPlayback to an empty set so that the camera feed starts without user interaction.

Optional: Prevent the second camera prompt (iOS 15+)

This step is not required for ID capture. Without it, iOS displays its own camera prompt for the Medallion page, and capture proceeds once the user allows access.

To prevent this second prompt, assign a WKUIDelegate to the WebView and implement webView(_:requestMediaCapturePermissionFor:initiatedByFrame:type:decisionHandler:). Grant the request when it originates from the Medallion host; otherwise, return the prompt decision.


Android configuration

Step 1: Declare and request the camera permission

Add the android.permission.INTERNET and android.permission.CAMERA permissions to your AndroidManifest.xml.

Before opening the Medallion link, confirm that your app holds the camera permission, and request it at runtime if it does not. The WebView can grant camera access to the page only after the app itself holds the permission.

Step 2: Configure the WebView

Apply the following settings to the WebView's WebSettings:

  • Set javaScriptEnabled to true.
  • Set domStorageEnabled to true.
  • Set mediaPlaybackRequiresUserGesture to false so that the camera feed starts without user interaction.
  • Set javaScriptCanOpenWindowsAutomatically to true.

Step 3: Grant camera access to the page

Assign a WebChromeClient to the WebView and override onPermissionRequest to grant the requested resources. Without this override, Android denies the page's camera request.


Cross-platform frameworks

React Native, Flutter and other cross-platform frameworks render web content in the same native components: WKWebView on iOS and WebView on Android. Each WebView library exposes these settings under its own names, so map each requirement in Requirements at a glance to the corresponding option in your library and enable it.

  • Library defaults. Do not rely on them. Inline playback and playback without user interaction are frequently disabled by default.
  • Page camera access on Android. Ensure that the page's camera request is granted. Some libraries grant it automatically; others require a permission request callback equivalent to onPermissionRequest.
  • Camera permission. Declare camera usage in your iOS and Android project files as described above. On Android, also request the permission at runtime before opening the link, unless your library does this for you.

Did this page help you?