LogoLogo
Useful links
  • Home
  • Product guides
  • API
  • SDKs
  • Overview
  • OUR SOLUTIONS
    • User Onboarding
    • ID Document Verification
    • Know Your Customer - KYC
    • Know Your Business - KYB
    • Account Takeover Prevention
  • USER GUIDE
    • Trust Platform
      • New Query
      • Executions
      • Company
      • Onboarding List
      • Onboarding Builder
      • Query Templates
      • Workflow Builder
    • Smart Auth (identity)
      • Getting Started
      • Access Token
      • Checking the Response
  • Quick Start Guides
    • Onboarding Journey
    • Company Search through API
    • Onboarding links into WebView and iFrame
      • WebView
        • Android
        • iOS
        • React Native
        • Flutter
      • iFrame
      • Events
LogoLogo

2025 © Caf. - All rights reserved

On this page
  • iOS Info.plist
  • iOS WebView (Swift)
  1. Quick Start Guides
  2. Onboarding links into WebView and iFrame
  3. WebView

iOS

This document provides instructions to create a WebView into an iOS project.

iOS Info.plist

Add these lines to the Info.plist file in you iOS module:

<key>NSCameraUsageDescription</key>
<string>Camera Permission</string>
<key>NSMotionUsageDescription</key>
<string>Motion Permission</string>

iOS WebView (Swift)

In order for web Onboarding integrations that use WKWebView for iOS to function properly, it is necessary to customize the configuration to allow media playback without request user's action and to reproduce the media inline.

For iOS, WKWebView is the preferred WebView. The example below is a basic illustration.

AppDelegate

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.rootViewController = WebViewController()
        window?.makeKeyAndVisible()
        return true
    }
}

SceneDelegate

import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = scene as? UIWindowScene else { return }

        window = UIWindow(windowScene: windowScene)
        window?.rootViewController = WebViewController()
        window?.makeKeyAndVisible()
    }
}

WebViewController

@preconcurrency import WebKit
import AVFoundation

class WebViewController: UIViewController, WKNavigationDelegate, WKUIDelegate {
    var webView: WKWebView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupViews()
        setupConstraints()
    }

    func setupViews() {
        let webConfiguration = WKWebViewConfiguration()
        webConfiguration.allowsInlineMediaPlayback = true
        webConfiguration.defaultWebpagePreferences.allowsContentJavaScript = true
        webConfiguration.mediaTypesRequiringUserActionForPlayback = []

        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.navigationDelegate = self
        webView.uiDelegate = self
        view.addSubview(webView)

        let request = URLRequest(url: URL(string: "https://cadastro.io/:token")!)
        webView.load(request)
        
        AVCaptureDevice.requestAccess(for: .video) { granted in
            if granted {
                // Access granted
            } else {
                // Access denied
            }
        }
    }

    func setupConstraints() {
        webView.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            webView.topAnchor.constraint(equalTo: view.topAnchor),
            webView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            webView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            webView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
        ])
    }
}

Last updated 2 months ago