Enrico
Enrico

Reputation: 6256

MAUI and IFingerprint: how to authenticate the user after a resume?

In my NET8 MAUI application, I added the IFingerprint in order to authenticate the user via biometrics. It is working if the app displays a login page.

What I like to do is authenticate the user when the app is restored. For example, I added this code in the App.xaml.cs

protected override async void OnResume()
{
    base.OnResume();

    var isAvailable = await CrossFingerprint.Current.IsAvailableAsync(true);

    if (isAvailable)
    {
        var request = new AuthenticationRequestConfiguration(
            "Login using biometrics", "Confirm login with your biometrics");
        request.AllowAlternativeAuthentication = true;

        var result = await CrossFingerprint.Current.AuthenticateAsync(request);

        Console.Write(result);
    }
}

The problem I get is that the app checks the user constantly not only when the app is resumed. What is the correct implementation or best practice?

Upvotes: 0

Views: 52

Answers (0)

Related Questions