The Keyless SDK uses three classes of errors, each error has a code and a description:
Internal errors: triggered by Keyless internals.
Integration errors: triggered by a KeylessSDK integration misconfiguration.
User errors: triggered by user behavior.
If you're implementing the Keyless SDK, you should handle these errors so they are not displayed to the end user. User errors are most likely to require application logic, and are explained in more detail below.
User errors
Note that many of these errors are predictions only, when writing messages for your users it's often best to assume positive intent. For example, suggest that they make sure that nothing is obstructing the camera instead of suggesting that are attempting to spoof.
Spoofing
The user might be placing a picture or a video in front of the camera.
Timeout
The operation timed out.
Mask detected
The user might be wearing a mask, or there might be something hiding their face.
User cancelled
The user manually cancelled the operation.
Face not matching
The face of the user trying to perform an operation is different from the face of the user who is enrolled.
No network connection
The device is offline.
User lockout
The user is temporarily locked out of Keyless after too many failed authentication attempts.
Examples
val configuration = Keyless.AuthenticationConfiguration()Keyless.authenticate( authenticationConfiguration = configuration, onCompletion = { result ->when (result) {is Keyless.KeylessResult.Success -> { Log.d("IntegratorActivity ", "Authenticate success") }is Keyless.KeylessResult.Failure -> {when (result.error) {is KeylessUserError.FaceNotMatching -> Log.d("IntegratorActivity ", "Face not matching")is KeylessUserError.MaskDetected -> Log.d("IntegratorActivity ", "Mask detected")is KeylessUserError.Spoofing -> Log.d("IntegratorActivity ", "Spoofing detected")is KeylessUserError.Timeout -> Log.d("IntegratorActivity ", "The operation timed out") is KeylessUserError.UserCancelled -> Log.d("IntegratorActivity ", "The user cancelled the operation")
is KeylessUserError.NoNetworkConnection -> Log.d("IntegratorActivity ", "No network connection available")
is KeylessUserError.Lockout -> Log.d("IntegratorActivity ", "Your account is temporarily locked")else-> { Log.d("IntegratorActivity ", "Authenticate failure")val errorCode = result.error.codeval errorMessage = result.error.messageval errorCause = result.error.cause?.printStackTrace()// here you could display a generic error popup with the error code } } } } })
let configuration = Keyless.AuthenticationConfiguration.builder.build()Keyless.authenticate(authenticationConfiguration: configuration) { result inswitch result {case .success(let authenticationSuccess):print("authenticationDidFinish: \(authenticationSuccess.token)")case .failure(let error):switch error.kind {case .userError(let userError):switch userError {case .faceNotMatching:print("Face not matching")case .maskDetected:print("Mask detected")case .spoofing:print("Spoofing detected")case .timeout:print("The operation timed out")case .userCancelled:print("The user cancelled the operation")case .noNetworkConnection:print("No network connection available")case .lockout:print("Your account is temporarily locked") }default:let code = error.codelet message = error.message// here you could display a generic error popup with the error code } }}