AuthenticationResultCallback


public fun interface AuthenticationResultCallback


A callback to be called when an AuthenticationResult is available.

Summary

Public methods

default void

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

abstract void

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

Public methods

onAuthAttemptFailed

Added in 1.4.0-alpha05
default void onAuthAttemptFailed()

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
abstract void onAuthResult(@NonNull AuthenticationResult result)

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
}
}
}