Building the SDK

Creating a Liveness SDK instance

In order to create an instance of CafFaceLivenessSDK, we need to use our CafBuilder. This allows you to configure all necessary configurations.

Builder Methods

Method
Type
Description
Required

setListener

Sets the listener for liveness verification events.

setStage

CafStage

Defines the environment stage (e.g., PROD, BETA). Default is PROD.

setScreenCaptureEnabled

Boolean

Enables or disables screen capture. Default is false.

setLoadingScreen

Boolean

Enables or disables the loading screen. Default is false.

setLivenessBaseUrl

String

Sets the reverse proxy URL for face liveness. Must be WSS protocol.

setDebugMode(Boolean)

Boolean

Enables or disables logs to aid debugging during the integration process. Default is false.

setCertificates

List

Sets Base64 encoded SHA-256 certificates for reverse proxy.

setAuthBaseUrl

String

Sets the reverse proxy URL for authentication. Must be HTTPS protocol.

Example

    private fun setupCafFaceLiveness() {
        sdk = CafFaceLivenessSDK.CafBuilder()
            .setStage(CafStage.PROD)
            .setScreenCaptureEnabled(true)
            .setLoadingScreen(true)
            .setListener(
                setupCafLivenessListener()
            ).build()
    }

    private fun setupCafLivenessListener() = object : CafLivenessListener {
        override fun onCancel() {
            println("onCancel")
        }

        override fun onError(sdkFailure: CafFaceLivenessError) {
            println("onError: ${sdkFailure.message}")
        }

        override fun onLoaded() {
            // This event will only be called when the loading screen isn't enabled
            println("onLoaded")
        }

        override fun onLoading() {
            // This event will only be called when the loading screen isn't enabled
            println("onLoading")
        }

        override fun onSuccess(livenessResult: CafFaceLivenessResult) {
            println("onSuccess: ${livenessResult.signedResponse}")
        }
    }

Last updated

Logo

2023 © Caf. - All rights reserved