Provides a cross-platform implementation of biometric authentication.
Supports iOS, macOS, Android and Windows.
This repository has been rewritten taking into account the API of the xamarin-fingerprint and Plugin.Maui.Biometric libraries
| Platform | Minimum Version Supported |
|---|---|
| iOS | 12.2+ |
| macOS | 15+ |
| Android | 5.0 (API 21) |
| Windows | 11 and 10 version 1809+ (build 17763) |
- Add NuGet package to your project:
<PackageReference Include="Oscore.Maui.Biometric" Version="2.0.0" />- iOS - Add
NSFaceIDUsageDescriptionto your Info.plist to describe the reason your app uses Face ID. (see Documentation). Otherwise the App will crash when you start a Face ID authentication on iOS 11.3+.
<key>NSFaceIDUsageDescription</key>
<string>This app requires Face ID for secure authentication and to provide a personalized experience.</string>- Android - Request the permission in
AndroidManifest.xml
<uses-permission android:name="android.permission.USE_FINGERPRINT" android:maxSdkVersion="27" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" android:minSdkVersion="28" />- Add the following to your
MauiProgram.csCreateMauiAppmethod:
builder
.UseMauiApp<App>()
+ .UseBiometricAuthentication()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Sed:nammibold.ttf", "OpenSansSemibold");
});- Use through
BiometricAuthentication.Currentor usingIBiometricAuthenticationfrom DI:
// You don't need to check if the device supports biometric authentication, the plugin does it for you
var result = await BiometricAuthentication.Current.AuthenticateAsync(
new AuthenticationRequest(
title: "Authenticate",
reason: "Please authenticate to proceed"));
if (result.IsSuccessful)
{
// User authenticated
}With the Hardware menu you can
- Toggle the enrollment status
- Trigger valid (⌘ ⌥ M) and invalid (⌘ ⌥ N) fingerprint sensor events
- start the emulator (Android >= 6.0)
- open the settings
- go to Security > Fingerprint, then follow the enrollment instructions
- when it asks for touch
- open the Emulator Settings
- go to Fingerprint menu
