-
Notifications
You must be signed in to change notification settings - Fork 15
IBiometric
Gulam Ali H edited this page Jun 9, 2024
·
2 revisions
The IBiometric
interface defines methods for biometric authentication.
Task<BiometricHwStatus> GetAuthenticationStatusAsync(AuthenticatorStrength authStrength = AuthenticatorStrength.Strong)
- Description: Asynchronously retrieves the hardware status of biometric authentication.
-
Parameters:
-
authStrength
: (Optional) The strength of the biometric authentication. Defaults toAuthenticatorStrength.Strong
. (This is only relevant on Android)
-
-
Returns:
- A
Task<BiometricHwStatus>
represents biometric authentication's hardware status.
- A
Task<AuthenticationResponse> AuthenticateAsync(AuthenticationRequest request, CancellationToken token)
-
Description: Asynchronously performs biometric authentication based on the provided
AuthenticationRequest
. -
Parameters:
-
request
: AnAuthenticationRequest
object specifying the authentication parameters. -
token
: ACancellationToken
is used to cancel the authentication process.
-
-
Returns:
- A
Task<AuthenticationResponse>
represents the authentication attempt's result.
- A
- Description: Asynchronously retrieves a list of enrolled biometric options available on this device. (This does not dictate what will be challenged to the user at the time of authentication)
-
Returns:
- A
Task<List<BiometricType>>
which retrieves all the available enrolled authentication options.
- A
var biometricStatus = await biometricService.GetAuthenticationStatusAsync();
// Handle biometricStatus based on the application's logic
if(biometricStatus!= BiometricStatus.Success)
return;
var authenticationRequest = new AuthenticationRequest
{
AllowPasswordAuth = true, // A chance to fallback to password auth
Title = "Authenticate", // On iOS only the title is relevant, everything else is unused.
Subtitle = "Please authenticate using your biometric data",
NegativeText = "Use Password", // if AllowPasswordAuth is set to true don't use this it will throw an exception on Android
Description = "Biometric authentication is required for access",
AuthStrength = AuthenticatorStrength.Strong // Only relevant on Android
};
var authenticationResponse = await biometricService.AuthenticateAsync(authenticationRequest, cancellationToken);