Using biometric identification in Xamarin Forms

It’s very likely that some of the applications that you have installed on your device uses fingerprints to simplify authentication before executing certain important or sensitive actions. We usually see this type of features in banking applications where you decide whether to access with your credentials or your fingerprint! And honestly I love using my fingerprint because it saves me a lot of time! ?

And it’s very easy to implement in Xamarin Forms! In this article we will be learning how to do it! Let’s see!

First of all, you have to take in consideration before implementing fingerprint in your project that:

➖  Not all devices have fingerprint recognition, therefore not 100% of your users will take advantage of this feature, for this reason it is extremely important to implement fingerprint identification as an additional option that is NOT unique.

➖  You can’t store the fingerprint received.

First of all… What do I need?

✔ Add from NuGet Package the plugin: Plugin.FingerPrint

This image has an empty alt attribute; its file name is Screen-Shot-2020-06-16-at-11.14.18-PM.png

Let’s start!

Platform settings

This image has an empty alt attribute; its file name is if_apple-ios-system-platform-os-mac-linux_652586.png In your info.plist add the following property:

Key:  NSFaceIDUsageDescription

Description: Add the purpose of using your Face ID in your App. For example: It’s required for login authentication. (It’s important to add this description if not your App will crash when you start a Face ID authentication on iOS 11.3+.)

This image has an empty alt attribute; its file name is if_android_313085.pngOpen you AndroidManifest.xml and check the UseFingerPrint permission. Then, open your MainActivity.cs and after Xamarin.Forms initialization add the following code:

Let’s code!

Let’s start with the AuthenticationRequestConfiguration object which it’s nothing more than the responsible to configure the stuff presented to the user. ⚠ The Title and the Reason are required

Then, with CrossFingerprint class you will be able to make your authentication (As parameter, it receives the variable declared in the step previously worked ):

Finally, your Result object will have different properties derived from your FingerPrint authentication: A boolean to determine If the user was Authenticated, some ErrorMessage obtained and a Status!

For example:

? What if you don’t have a physical device?

Relax! You can test it in your emulador! Let’s learn how to do it!

?  On Iphone: With the simulator open , go to device  ➡ Features  ➡ Face ID  ➡ Enrolled.

?  On Android: Locate you emulator ➡ Settings (…)  ➡ Fingerprint ➡ Click on “Touch the sensor” button.

Thanks for reading! ?

Artículo en español:  https://medium.com/@reyes.leomaris/usando-identificación-biométrica-en-xamarin-forms-fce6c2c6477

References: https://github.com/smstuebe/xamarin-fingerprint

Tagged ,

1 thought on “Using biometric identification in Xamarin Forms

Leave a Reply

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