Biometrics enrollment & authentication in Xamarin Forms

VPrasanth 51 Reputation points
2021-10-25T17:02:24.493+00:00

I need some help in addressing the below use cases, using Xamarin Forms.
Does anyone had implemented the below use cases either using Xamarin Android / Xamarin iOS or Xamarin Forms.

  1. The app needs to identify if biometric sensors are available or not.
  2. The app to allow the option to enroll biometrics (Fingerprint / FaceId for iOS) even if the device not have finger prints enrolled.

I tried using Plugin.Fingerprint, the IsAvailable method works only when there are fingerprint enrolled on the device.
It's not helping to enroll the user for biometrics even if the device authenticaiton is not biometrics.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,315 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 70,966 Reputation points Microsoft Vendor
    2021-10-26T05:57:00.58+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Does anyone had implemented the below use cases either using Xamarin Android / Xamarin iOS or Xamarin Forms.

    The app needs to identify if biometric sensors are available or not.

    The app to allow the option to enroll biometrics (Fingerprint / FaceId for iOS) even if the device not have finger prints enrolled.

    For Xamarin.android, AndroidX provide an Api to check it if biometric sensors are available or not. Or biometric if is enrolled.

    Firstly, you need to install this nuget package.Xamarin.AndroidX.Biometric

    Then Use following code to judge if is enrolled the biometrics. If not, open the setting's package(Please ignore the waring, because this is a new api for Google).

       var biometricErrorNoneEnrolled = (int)AndroidX.Biometric.BiometricManager.BiometricErrorNoneEnrolled;  
                   if (AndroidX.Biometric.BiometricManager.From(ApplicationContext).CanAuthenticate()== biometricErrorNoneEnrolled)  
                   {  
                       StartActivity(new Intent(Android.Provider.Settings.ActionSecuritySettings));  
                   }  
    

    For iOS, You can check this document about Check the availability of biometric hardware.

    https://learn.microsoft.com/en-us/xamarin/ios/platform/touch-id-face-id

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments