SDK Lifecycle

CafVerifyPolicyListener

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

Event
Description

onCanceled(failure: CafSmartAuthError)

Triggered when the user cancels the process, with error details provided in failure.

onError(failure: CafSmartAuthError)

Called on SDK failure, with error details provided in failure.

onPending(isAuthorized: Bool, attestation: String)

Called when the SDK is waiting for a result.

onLoaded()

Triggered when the SDK is ready.

onLoading()

Indicates the SDK is initializing.

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

Called upon successful detection, with the result provided.

Example

private func setupListener() -> CafVerifyPolicyListener {
    return { result in
        switch result {
        case .onSuccess(let response):
            print("CafVerifyPolicyListener.onSuccess isAuthorized: \(response.isAuthorized)")
            print("CafVerifyPolicyListener.onSuccess attestation: \(response.attestation)")
        
        case .onPending(let response):
            print("CafVerifyPolicyListener.onPending isAuthorized: \(response.isAuthorized)")
            print("CafVerifyPolicyListener.onPending attestation: \(response.attestation)")
        
        case .onError(let error):
            print("CafVerifyPolicyListener.onError failure: \(error.localizedDescription)")

        case .onCanceled(let error):
            print("CafVerifyPolicyListener.onCanceled failure: \(error.localizedDescription)")
        
        case .onLoading(let isLoading):
            print("CafVerifyPolicyListener.onLoading isLoading: \(isLoading)")
        
        case .onLoaded(let isLoaded):
            print("CafVerifyPolicyListener.onLoaded isLoaded: \(isLoaded)")
        }
    }
}

Last updated

Logo

2023 © Caf. - All rights reserved