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

ParameterRequiredDescription

setScreenCaptureEnabled(Boolean)

No

Enables or disables screen capture. Default is false.

setStage(CAFStage)

No

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

setLoadingScreen(Boolean)

No

Enables or disables the loading screen. Default is false.

setLivenessBaseUrl(String)

No

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

setDebugMode(Boolean)

No

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

setCertificates(List<String>)

No

Sets Base64 encoded SHA-256 certificates for reverse proxy.

setAuthBaseUrl(String)

No

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

setListener(CafLivenessListener)

Yes

Sets the listener for liveness verification events.

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