question

VaranasiPrasanth-3918 avatar image
0 Votes"
VaranasiPrasanth-3918 asked LeonLu-MSFT edited

Biometrics enrollment & authentication in Xamarin Forms

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.



dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LeonLu-MSFT avatar image
0 Votes"
LeonLu-MSFT answered LeonLu-MSFT edited

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://docs.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.


image.png (8.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.