For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Pular para o conteúdo

Source Code

import UIKit
import CafFaceLivenessLite

final class MainViewController: UIViewController {
    private let sdk = CafFaceLivenessLiteSDK(enableSecurity: true)

    override func viewDidLoad() {
        super.viewDidLoad()
        sdk.delegate = self

        sdk.setup(
            mobileToken: "mobileToken",
            personId: "personId",
            customLocalization: nil,
            customLocalizationBundle: nil,
            environment: .prod,
            loading: true
        )
        // Optional: overlap the session request with whatever the user does next
        sdk.prewarm()

        let startButton = UIButton(type: .system)
        startButton.setTitle("Start Liveness Lite", for: .normal)
        startButton.addTarget(self, action: #selector(startLivenessLite), for: .touchUpInside)
        view.addSubview(startButton)
        // Layout omitted
    }

    @objc private func startLivenessLite() {
        sdk.startSDK(viewController: self)
    }
}

extension MainViewController: CafFaceLivenessLiteDelegate {
    func didFinishWithSuccess(livenessResult: CafFaceLivenessLiteResult) {
        // Opaque JWT from async route — resolve final result on your backend
        print("Success: \(livenessResult.signedResponse ?? "-")")
    }

    func didFinishWithFailure(type: CafFailureType, description: String?, signedResponse: String?) {
        print("Failure: type=\(type) desc=\(description ?? "-") signed=\(signedResponse ?? "-")")
    }

    func didFinishWithError(type: CafErrorType, description: String) {
        print("Error: type=\(type) desc=\(description)")
    }

    func cancelled() { print("Cancelled") }
    func loading() { print("Loading") }
    func loaded() { print("Loaded") }
}

Atualizado