Webview Integration

Flow version supported: v1.2 (or earlier)

Embed the H5 identity verification flow in a webview to keep users inside your native Android or iOS app instead of redirecting to an external browser.

Prerequisites

  • Obtain a launch URL by calling the Initiate Flow API
  • Ensure your app has camera permission declared in its manifest (Android) or Info.plist (iOS)

Integration Steps

Step 1: Override WebChromeClient for camera access

Override WebChromeClient to handle camera permission requests within the webview. The H5 flow requires camera access for selfie capture.

private var mWebChromeClient: WebChromeClient = object : WebChromeClient() {
    override fun onPermissionRequest(request: PermissionRequest?) {
        if (ContextCompat.checkSelfPermission(
                this@DemoH5Activity,
                Manifest.permission.CAMERA
            ) == PackageManager.PERMISSION_GRANTED
        ) {
            request?.grant(request.resources)
        } else {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                requestPermissions(
                    arrayOf(Manifest.permission.CAMERA),
                    REQUEST_CAMERA_PERMISSION
                )
            }
        }
    }

    override fun onShowCustomView(view: View, callback: CustomViewCallback) {}

    override fun onHideCustomView() {}	
}

Step 2: Initialize the webview and load the launch URL

Configure the webview with JavaScript enabled and user-gesture-free media playback, then load your launch URL. Replace https://xxx with the actual URL from the Initiate Flow API.

webview.apply {
    settings.apply {
        javaScriptEnabled = true
        mediaPlaybackRequiresUserGesture = false
    }

    webChromeClient = mWebChromeClient

    loadUrl("https://xxx")
}

Handling Redirection

After the flow completes, fails, or the user exits, they are redirected back to your application. The redirect URL includes query parameters indicating the flow outcome.

📄

For the full specification of query parameters and status codes returned during redirection, refer to the Partner Redirection document.