Start Smart Authentication

Calling verifyPolicy

To start the liveness verification, use the verifyPolicy() method with the user's document ID, your account mobile token, and a CafVerifyPolicyListener closure.

Parameter
Type
Description
Required

mobileToken

String

Usage token associated with your CAF account.

personID

String

User's document ID.

listener

Closure that handles key events during the SDK's liveness detection process.

Example

private func startSdk() {
    smartAuth?.verifyPolicy(
        personID: "userDocument",
        policyId: "myPolicyId",
        listener: setupListener()
    )
}

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