AuthenticationResultCallback


fun interface AuthenticationResultCallback


A callback to be called when an AuthenticationResult is available.

Summary

Public functions

open Unit

The callback to be called if an authentication attempt has failed due to a wrong biometric recognition (e.g. wrong fingerprint, wrong face).

Unit

Called when the authentication process is completed successfully or with an error.

Public functions

onAuthAttemptFailed

Added in 1.4.0-alpha05
open fun onAuthAttemptFailed(): Unit

The callback to be called if an authentication attempt has failed due to a wrong biometric recognition (e.g. wrong fingerprint, wrong face). This callback will be called for every failed attempt, if any.

For example:

override fun onAuthAttemptFailed() {
// Track how many times a user fails (e.g., for internal analytics).

// Note: Do NOT show a Toast or Dialog here usually, because the system UI
// already shows "Not recognized" text on Biometric Prompt.
}

onAuthResult

Added in 1.4.0-alpha05
fun onAuthResult(result: AuthenticationResult): Unit

Called when the authentication process is completed successfully or with an error.

The authentication result will contain the details about the result.

This callback will always be called once and only once per authentication session.

For example:

override fun onAuthResult(result: AuthenticationResult) {
when (result) {
is AuthenticationResult.Success -> {
// Handle success
}
is AuthenticationResult.Error -> {
// Handle authentication error, e.g. negative button click, user
// cancellation, etc
}
}
}