9. Handling Failures
When the verification process fails, a VerificationOutcome.Failed
object is returned. This object includes a Reason
class that indicates the reason for the failure. The VerificationOutcome.Failed
class and the Reason
enum are defined as follows:
data class Failed(val reason: Reason): VerificationOutcome
enum class Reason {
LIVENESS_FAILED,
CANCELLED,
INVALID_TOKEN,
VERIFICATION_FAILED,
UNAUTHORIZED,
LOCATION_SERVICE_UNAVAILABLE,
LOCATION_PERMISSION_DENIED,
CAMERA_PERMISSION_DENIED,
UNKNOWN,
}
Here is a list of the possible reasons for failure:
LIVENESS_FAILED
: This reason is triggered when the user fails the liveness test during the verification process.CANCELLED
: This reason occurs when the user exits the SDK before the verification process is completed. For example, if the user cancels out of the verification process.INVALID_TOKEN
: This reason is triggered when an invalid or expired token is passed to the SDK for verification.VERIFICATION_FAILED
: This reason occurs when a user's verification attempt fails for any reason.UNAUTHORIZED
: This reason is triggered when incorrect clientKey and/or secretKey are used for authentication.UNKNOWN
: This reason represents an error that occurs outside the ordinary situations. It's a catch-all for unexpected errors.LOCATION_SERVICE_UNAVAILABLE
: Happens when the user’s location services are turned off. (Triggered only inStripped
launch configuration)LOCATION_PERMISSION_DENIED
: Happens when the user denies request for “precise” location permissions. (Triggered only inStripped
launch configuration)CAMERA_PERMISSION_DENIED
: Happens when the user denies request for camera permissions (Triggered only inStripped
launch configuration)
When you receive a VerificationOutcome.Failed
object, you can use the Reason
property to determine the specific reason for the failure. This information allows you to handle different failure scenarios appropriately in your app.