Skip to content

Native Bridge

psandrinelli edited this page Jul 5, 2023 · 9 revisions

Introduction

iProov's Web SDK provides a feature-complete implementation of iProov, developed purely in web technologies and runs in all modern browsers.

However, until iOS 14.3, iOS did not support camera access from WebView-based apps. Therefore, if you have built a WKWebView-based app, you will find that the Web SDK fails to work properly, either if using iOS < 14.3, or integrating iProov Web <3.1.0.

To solve this issue, starting with iOS SDK v7.3 and Web SDK (previously known as HTML5) 2.0, we now provide a Native Bridge which will seamlessly launch the native iOS SDK from your WebView-based app, iProov the user, and then transparently deliver the callbacks to your WebView-based app.

This has been designed to require minimal implementation changes to your app, by translating the native callbacks into JavaScript events.

We have also implemented this in such a way that if your webpages are served both in-app (via a WebView) and also via a conventional browser, users can iProov either via the Web SDK or native SDK, depending on whether camera acccess is supported.

In iOS SDK v7.5 and Web SDK v2.1 we have introduced Native Bridge 2.0.

Please consult the following table to determine which Native Bridge version is supported in your iProov SDK version:

iOS SDK Native Bridge Web SDK
SDK v7.2 and older Unsupported Unsupported
SDK v7.3 and v7.4 Native Bridge 1.0 >=2.0.0 <3.0.0
SDK v7.5 and newer Native Bridge 2.0 >=2.1.0

NOTE: Only iOS SDK v9.1 and newer support Native Bridge when launched from within an IFrame.

Installation

Installation (web)

You need to integrate the iProov Web SDK into your app's webpage(s). Follow the integration instructions here.

TIP: Once the iProov Web SDK has been integrated, test it is working properly in a conventional browser (e.g. Mobile Safari) before proceeding.

Installation (app)

You need to add the iProov iOS SDK to your native app. Follow the installation instructions here.

NOTE: You only need to follow the "Installation" instructions, not "Get Started".

The instructions now differ depending on whether you are using Native Bridge 2.0 or 1.0 (legacy).


Native Bridge 2.0

Implementation (web)

No further work is required.

Implementation (app)

  1. Use import iProov to import the iProov iOS SDK in the file where your WKWebView is declared.

  2. Make sure your WKWebviewConfiguration contains the following settings:

config.requiresUserActionForMediaPlayback = false
config.allowsInlineMediaPlayback = true
  1. As early as possible in the lifecycle of your WKWebView (e.g. in your view controller's viewDidLoad method), call webView.installIProovNativeBridge().

Native Bridge 1.0

Implementation (web)

You need to make sure you set the prefer_app attribute on your <iproov-me> element, so that the Web SDK will attempt to launch the native SDK when the launch button is pressed. You should either set it to "always" (for pages that are only ever accessed via a WebView), or "ios-webview" (if the pages are served both via WebViews and via traditional browsers).

Implementation (app)

  1. Use import iProov to import the iProov iOS SDK in the file where your WKWebView is declared.

  2. You need to ensure that your WKWebView has a navigationDelegate set. If you're doing any kind of interception of navigation events in your app, chances are you have properly set this already. If not, set it before you continue:

    webView.navigationDelegate = self
  3. You need to pass the iProov SDK navigation events so that it will be launched when requested by the Web SDK:

    extension MyViewController: WKNavigationDelegate {
    
        func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
    
            guard navigationAction.navigationType == .linkActivated,
                let url = navigationAction.request.url,
                IProov.handle(url: url, from: webView) else {
    
                decisionHandler(.allow)
                return
            }
    
            decisionHandler(.cancel)
        }
    
    }

    Note: The IProov.handle() call is only ever used to determine whether to launch the native SDK in response to the navigation event, and this is done locally on-device. iProov does not monitor or collect the navigation events in your app. If you are concerned about this call from a privacy perspective, you can feel free to add an additional check to only pass iProov URL's with the host iproov.app.


🎉 Congratulations! You have now successfully integrated the Web/Native bridge. You can now try launching the iProov Web SDK from within your WebView-based app. You should find that the native SDK is launched, and then delivers the callbacks straight back to the Web SDK.

If you require further assistance, please contact iProov support.