SDK Lifecycle

CafLivenessListener

The CafLivenessListener interface handles key events during the SDK's liveness detection process:

Event
Description

onCancel()

Triggered when the user cancels the process.

onError(sdkFailure: CafFaceLivenessError)

Called on SDK failure, with error details provided.

onLoaded()

Triggered when the SDK is ready, if the loading screen is disabled.

onLoading()

Indicates the SDK is initializing, called if no loading screen is shown.

onSuccess(livenessResult: CafFaceLivenessResult)

Called upon successful detection, with the result in livenessResult.signedResponse.

Example

    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