Plugin.Fingerprint.MAUI
2.0.1
dotnet add package Plugin.Fingerprint.MAUI --version 2.0.1
NuGet\Install-Package Plugin.Fingerprint.MAUI -Version 2.0.1
<PackageReference Include="Plugin.Fingerprint.MAUI" Version="2.0.1" />
<PackageVersion Include="Plugin.Fingerprint.MAUI" Version="2.0.1" />
<PackageReference Include="Plugin.Fingerprint.MAUI" />
paket add Plugin.Fingerprint.MAUI --version 2.0.1
#r "nuget: Plugin.Fingerprint.MAUI, 2.0.1"
#:package Plugin.Fingerprint.MAUI@2.0.1
#addin nuget:?package=Plugin.Fingerprint.MAUI&version=2.0.1
#tool nuget:?package=Plugin.Fingerprint.MAUI&version=2.0.1
Biometric / Fingerprint plugin for Maui
Maui and MvvMCross plugin for accessing the fingerprint, Face ID or other biometric sensors.
Setup
iOS
Add NSFaceIDUsageDescription to 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>Need your face to unlock secrets!</string>
Android
Request the permission in AndroidManifest.xml
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
Set the resolver of the current Activity
Skip this, if you use the MvvMCross Plugin or don't use the dialog.
MAUI apps have a single Activity. Wire it up in MainActivity.cs:
using Android.App;
using Android.OS;
using Microsoft.Maui;
using Plugin.Fingerprint;
namespace YourApp;
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Required — the plugin uses the Activity to show BiometricPrompt.
CrossFingerprint.SetCurrentActivityResolver(() => this);
}
}
Windows
Add the capability inside Package.appxmanifest:
<Capabilities>
<DeviceCapability Name="fingerprint" />
</Capabilities>
MAUI Program Setup
Register the plugin with MAUI’s DI container (skip if using MvvmCross — Plugin.cs Load() handles registration):
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Hosting;
using Plugin.Fingerprint;
using Plugin.Fingerprint.Abstractions;
namespace YourApp;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});
// Register IFingerprint as a singleton so it can be injected into ViewModels.
builder.Services.AddSingleton<IFingerprint>(_ => CrossFingerprint.Current);
return builder.Build();
}
}
Usage
Example
vanilla
var request = new AuthenticationRequestConfiguration ("Prove you have fingers!", "Because without it you can't have access");
var result = await CrossFingerprint.Current.AuthenticateAsync(request);
if (result.Authenticated)
{
// do secret stuff :)
}
else
{
// not allowed to do secret stuff :(
}
using MvvMCross
var fpService = Mvx.Resolve<IFingerprint>(); // or use dependency injection and inject IFingerprint
var request = new AuthenticationRequestConfiguration ("Prove you have mvx fingers!", "Because without it you can't have access");
var result = await fpService.AuthenticateAsync(request);
if (result.Authenticated)
{
// do secret stuff :)
}
else
{
// not allowed to do secret stuff :(
}
Using MAUI with Dependency Injection
Inject IFingerprint into a ViewModel:
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Plugin.Fingerprint.Abstractions;
namespace YourApp.ViewModels;
public partial class LoginViewModel : ObservableObject
{
private readonly IFingerprint _fingerprint;
public LoginViewModel(IFingerprint fingerprint)
{
_fingerprint = fingerprint;
}
[RelayCommand]
async Task AuthenticateAsync()
{
var config = new AuthenticationRequestConfiguration(
title: "Verify your identity",
reason: "Authenticate to access your account")
{
CancelTitle = "Cancel",
FallbackTitle = "Use PIN",
AllowAlternativeAuthentication = true,
};
var availability = await _fingerprint.GetAvailabilityAsync(
allowAlternativeAuthentication: config.AllowAlternativeAuthentication);
if (availability != FingerprintAvailability.Available)
{
await Shell.Current.DisplayAlert("Unavailable",
$"Biometric auth not available: {availability}", "OK");
return;
}
var result = await _fingerprint.AuthenticateAsync(config);
if (result.Authenticated)
{
// success — navigate or unlock
}
else
{
await Shell.Current.DisplayAlert("Failed",
result.ErrorMessage ?? result.Status.ToString(), "OK");
}
}
}
Nice to know
Android code shrinker (Proguard & r8)
If you use the plugin with Link all, Release Mode and ProGuard/r8 enabled, you may have to do the following:
- Create a
proguard.cfgfile in your android project and add the following:
-dontwarn com.samsung.**
-keep class com.samsung.** {*;}
- Include it to your project
- Properties > Build Action > ProguardConfiguration
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 is compatible. net10.0-ios26.0 is compatible. net10.0-maccatalyst26.0 is compatible. net10.0-windows10.0.19041 is compatible. net11.0-android36.1 is compatible. net11.0-ios26.4 is compatible. net11.0-maccatalyst26.4 is compatible. net11.0-windows10.0.19041 is compatible. |
-
net10.0-android36.0
- Xamarin.AndroidX.Biometric (>= 1.1.0.32)
-
net10.0-ios26.0
- No dependencies.
-
net10.0-maccatalyst26.0
- No dependencies.
-
net10.0-windows10.0.19041
- No dependencies.
-
net11.0-android36.1
- Xamarin.AndroidX.Biometric (>= 1.1.0.32)
-
net11.0-ios26.4
- No dependencies.
-
net11.0-maccatalyst26.4
- No dependencies.
-
net11.0-windows10.0.19041
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.