Skip to content

Learn Mobile Development

Alamgeer's Blog

Menu
  • Home
  • Privacy Policy
Menu
Biometric authentication in Xamarin

Implementation Of Biometric Authentication in Xamarin Forms

Posted on November 28, 2022January 18, 2023 by Learn Mobile Development

Now a days most of the mobile applications that use biometric authentication to secure data access. This allows users to authenticate via the fingerprint sensor and the face ID on those devices that have these capabilities. In this article, I’m going to show you how to add Biometric Authentication in Xamarin Forms application.

Let’s Start

In this sample demo we will use Plugin.Fingerprint nuget package.

Plugin.Fingerprint

Plugin.Fingerprint enables us to authenticate the user via fingerprint or face id or any other biometric.

1 – Install Plugin.Fingerprint nuget

Xamarin Forms Biometric Authentication

2 – iOS Setup

2.1 – Add “NSFaceIDUsageDescription” to your Info.plist to describe the reason your app uses Face ID

<key>NSFaceIDUsageDescription</key>
<string>Need your face to unlock secrets!</string>

thats it for iOS Let’s move to android setup.

3 – Android Setup

3.1 – Add “USE_FINGERPRINT” permission in manifest file

<uses-permission android:name="android.permission.USE_FINGERPRINT" />

Set “Resolver” in “OnCreate()” method of MainActivity.cs

CrossFingerprint.SetCurrentActivityResolver(() => Xamarin.Essentials.Platform.CurrentActivity);

Now, Setup is completed for android as well.

4 – Setting up the UI

4.1 – Creating a MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="XFBiometric.MainPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">

    <StackLayout>
        <Frame
            Padding="24"
            BackgroundColor="#2196F3"
            CornerRadius="0">
            <Label
                Margin="0,20,0,0"
                FontSize="36"
                HorizontalTextAlignment="Center"
                Text="Biometric Sample"
                TextColor="White" />
        </Frame>


        <StackLayout
            x:Name="StackContainer"
            Margin="0,150,0,0"
            IsVisible="False"
            VerticalOptions="CenterAndExpand">

            <Image
                x:Name="ImgSuccess"
                HeightRequest="200"
                WidthRequest="200" />

            <Label
                x:Name="LblMsg"
                FontAttributes="Bold"
                FontSize="25"
                HorizontalTextAlignment="Center"
                TextColor="Gray" />

        </StackLayout>

        <Button
            x:Name="BtnAuthenticate"
            Margin="0,0,0,50"
            Padding="20,15"
            BackgroundColor="#2196F3"
            Clicked="OnAuthenticateClicked"
            CornerRadius="30"
            FontAttributes="Bold"
            FontSize="20"
            HorizontalOptions="Center"
            Text="Authenticate"
            TextColor="White"
            VerticalOptions="EndAndExpand" />

    </StackLayout>
</ContentPage>

4.2 – MainPage.xaml.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plugin.Fingerprint;
using Plugin.Fingerprint.Abstractions;
using Xamarin.Forms;

namespace XFBiometric
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        async void OnAuthenticateClicked(System.Object sender, System.EventArgs e)
        {
            var availability = await CrossFingerprint.Current.IsAvailableAsync();

            if (!availability)
            {
                StackContainer.IsVisible = false;
                await DisplayAlert("Warning!", "No biometrics available", "OK");

                return;
            }

            var authResult = await CrossFingerprint.Current.AuthenticateAsync(new AuthenticationRequestConfiguration("Heads up!", "Please validate biometric !!"));

            if (authResult.Authenticated)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    StackContainer.IsVisible = true;
                    ImgSuccess.Source = ImageSource.FromFile("success.png");
                    LblMsg.Text = "Authentication Successfully !!";
                });
            }
            else
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    StackContainer.IsVisible = true;
                    ImgSuccess.Source = ImageSource.FromFile("cross.jpg");
                    LblMsg.Text = "Authentication Failed !!";
                });
            }
        }
    }
}

5 – Result

That’s all for now!

You can check the full source code here.

Happy Coding! 😀

You may also like

Item reordering to CollectionView

How to apply item reordering to CollectionView GridItemsLayout in MAUI

MediaElement in Xamarin Forms

How to use MediaElement in Xamarin Forms

Post Views: 344
Share article with

2 thoughts on “Implementation Of Biometric Authentication in Xamarin Forms”

  1. ryzen sunucu kirala says:
    November 4, 2025 at 9:48 PM

    Thank you for sharing your personal experience and wisdom with us Your words are so encouraging and uplifting

    Reply
  2. knight online makro says:
    February 12, 2026 at 11:17 AM

    Your blog is always a highlight of my day

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

I'm Alamgeer Ashraf and having 11+ years of experience in enterprises mobile application development with Xamarin Native, Xamarin Forms & .Net MAUI.

Archives

  • February 2023 (1)
  • January 2023 (9)
  • December 2022 (5)
  • November 2022 (6)

Latest Posts

  • Prevent Dark Mode in Xamarin forms
    How to Prevent Dark Mode in Xamarin formsFebruary 3, 2023
  • apply color to Images
    How to apply color to Images and Icons in MAUIJanuary 30, 2023
  • iOS Large Page Title
    How to set iOS large page title in MAUIJanuary 26, 2023
  • Change StatusBar Color
    How to change StatusBar color in MAUIJanuary 22, 2023
  • Item reordering to CollectionView
    How to apply item reordering to CollectionView GridItemsLayout in MAUIJanuary 18, 2023

Popular Posts

  • How to Prevent Dark Mode in Xamarin forms
  • How to use Field Modifiers in MAUI
  • How to rotate views on orientation change in Xamarin Forms

Latest Comments

  1. knight online makro on Implementation Of Biometric Authentication in Xamarin FormsFebruary 12, 2026

    Your blog is always a highlight of my day

  2. dịch vụ backlink top.com vn on How to use CollectionView as a GridItemLayout in Xamarin FormsNovember 20, 2025

    Great post, you have pointed out some fantastic details , I besides think this s a very superb website.

  3. ryzen sunucu kirala on Implementation Of Biometric Authentication in Xamarin FormsNovember 4, 2025

    Thank you for sharing your personal experience and wisdom with us Your words are so encouraging and uplifting

  4. dofollow backlinks means on How to use FlexLayout in MAUIOctober 29, 2025

    Perfect piece of work you have done, this site is really cool with superb info .

  5. backlinks que es on How to use ObservableObject in MAUI for Data BindingOctober 28, 2025

    I like this internet site because so much useful stuff on here : D.

Our Visitor

0 0 9 0 3 5
Users Today : 3
Users Yesterday : 5
Users Last 7 days : 24
Users Last 30 days : 122
Users This Month : 105
Total views : 15484
How to use DockLayout in MAUI
Trending
How to use DockLayout in MAUI

Category

  • .Net MAUI
  • MAUI Community Toolkit
  • MVVM
  • Xamarin Community Toolkit
  • Xamarin Forms

Contact Me

  • LinkedIn
      © 2026 Learn Mobile Development