SDK Lifecycle

CafVerifyPolicyListener

The CafVerifyPolicyListener interface handles key events during the SDK's authentication:

Event
Description

onCancel()

Triggered when the user cancels the process.

onError(failure: CafFailure)

Called on SDK failure, with error details provided.

onPending(isAuthorized: Boolean, attestation: String)

Called when the SDK is waiting for the a result.

onLoaded()

Triggered when the finished an operation.

onLoading()

Indicates the SDK is starting an operation.

onSuccess(isAuthorized: Boolean, attemptId: String?, attestation: String?)

Called upon successful detection, with the result provided.

Example

    private fun setupListener() = object : CafVerifyPolicyListener {
        override fun onSuccess(
            isAuthorized: Boolean,
            attemptId: String?,
            attestation: String?
        ) {
            println("CafVerifyPolicyListener.onSuccess isAuthorized: $isAuthorized")
            println("CafVerifyPolicyListener.onSuccess attemptId: $attemptId")
            println("CafVerifyPolicyListener.onSuccess attestation: $attestation")
        }

        override fun onPending(isAuthorized: Boolean, attestation: String) {
            println("CafVerifyPolicyListener.onPending isAuthorized: $isAuthorized")
            println("CafVerifyPolicyListener.onPending attestation: $attestation")
        }

        override fun onError(failure: CafFailure) {
            println("CafVerifyPolicyListener.onError failure: ${failure.message}")
        }

        override fun onCancel() {
            println("CafVerifyPolicyListener.onCancel")
        }

        override fun onLoading() {
            println("CafVerifyPolicyListener.onLoading")
        }

        override fun onLoaded() {
            println("CafVerifyPolicyListener.onLoaded")
        }
    }

Last updated

Logo

2023 © Caf. - All rights reserved