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
In your info.plist add the following property:
➖ 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+.)
Open you AndroidManifest.xml and check the
UseFingerPrint permission. Then, open your MainActivity.cs and after Xamarin.Forms initialization add the following 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!
📱 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! 💚