{"id":20558,"date":"2017-10-17T11:13:23","date_gmt":"2017-10-17T16:43:23","guid":{"rendered":"https:\/\/www.solutionanalysts.com\/blog\/how-to-add-fingerprint-authentication-to-your-app-tutorial\/"},"modified":"2023-08-16T23:14:53","modified_gmt":"2023-08-17T04:44:53","slug":"how-to-add-fingerprint-authentication-to-your-app-tutorial","status":"publish","type":"post","link":"https:\/\/www.solutionanalysts.com\/blog\/how-to-add-fingerprint-authentication-to-your-app-tutorial\/","title":{"rendered":"How to add fingerprint authentication to your app &#8211; Tutorial"},"content":{"rendered":"<p>In this tutorial, we will show you how to add fingerprint authentication to your app.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"What_are_advantages_about_fingerprint_authentication\"><\/span><strong>What are advantages about fingerprint authentication?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>Fast and easy to use<\/li>\n<li>Secure: fingerprint uniquely identifies you<\/li>\n<li>Online transaction is safer<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"How_to_implement_fingerprint_authentication_in_your_app\"><\/span><strong>How to implement fingerprint authentication in your app<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>Verify that the lock screen is secure, or in other words, it is protected by PIN, password or pattern<\/li>\n<li>Verify that at least one fingerprint is registered on the smartphone<\/li>\n<li>Get access to Android keystore to store the key used to encrypt\/decrypt an object<\/li>\n<li>Generate an encryption key and the Cipher<\/li>\n<li>Start the authentication process<\/li>\n<li>Implement a callback class to handle authentication events<\/li>\n<\/ul>\n<p>These are several steps to follow to enable fingerprint authentication.<\/p>\n<p>That\u2019s all!!<\/p>\n<p>But&#8230;Still, you have to write lots of code to implement that.<br \/>\nWell here is an easy way to implement this in your app by writing 5 &#8211; 10 lines in your code.<\/p>\n<p>I have created one module library which will do all of the above for you and by writing very little code you can implement the fingerprint authentication in your app in just 5 mins and in any way you want.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Follow_these_steps\"><\/span><strong>Follow these steps,<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Step_%E2%80%93_1_Add_dependency_to_gradle\"><\/span><strong>Step &#8211; 1 Add dependency to gradle<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Add this dependency to your modules gradle file,<\/p>\n<pre class=\"lang:php\">implementation 'com.sa.hardik:fingerprintauthentication:0.1'<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Step_%E2%80%93_2_Implement_Callback\"><\/span><strong>Step &#8211; 2 Implement Callback<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>You can either implement this in your class and override the methods or you can pass it as a constructor parameter,<\/p>\n<pre class=\"lang:php\">Class MainActivity : AppcompactActivity(), FingerprintHandlerCallback {\r\n\t\t\u2026\u2026\r\n\t\t\r\n\t\toverride fun success(){\r\n\t\t\t\/\/Todo on successful fingerprint authentication\r\n}\r\n\r\n\t\toverride fun error(errorMsg : String){\r\n\t\t\t\/\/Todo on error in fingerprint authentication\r\n}\r\n\r\n}<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Step_%E2%80%93_3_Initialize_the_Fingerprint_Authentication\"><\/span><strong>Step &#8211; 3 Initialize the Fingerprint Authentication<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"lang:php\">val fManager = FingerprintManagerHelper(context, \"MYKEY\", callback)\r\n\tfManager.initFingerprint()\r\n\r\nHere,\r\ncontext \t- Context reference of your activity or application\r\nMYKEY \t- Encryption KEY\r\nCallback \t- Reference of \u2018FingerprintHandlerCallback\u2019 implemented in library to get\r\nsuccess and error callback<\/pre>\n<p>That&#8217;s it !!!!<\/p>\n<p>You have successfully implemented the fingerprint authentication in your app.<\/p>\n<p>You can use the same for payment authentication as well.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/4xrCMxk3PiQ\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>You can also download the full demo from this <a href=\"https:\/\/github.com\/nightfox8\/FingerprintAuthenticationExample\" target=\"_blank\" rel=\"noopener\">Github URL<\/a>.<\/p>\n<p>Note : There are many devices which do not have a\u00a0fingerprint sensor, In that case, you will receive an error callback at the time of initialization.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will show you how to add fingerprint authentication to your app. What are advantages about fingerprint authentication? Fast and easy to use Secure: fingerprint uniquely identifies you Online transaction is safer How to implement fingerprint authentication in your app Verify that the lock screen is secure, or in other words, it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":20559,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[198],"tags":[],"class_list":["post-20558","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ios-apps"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/posts\/20558","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/comments?post=20558"}],"version-history":[{"count":1,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/posts\/20558\/revisions"}],"predecessor-version":[{"id":32941,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/posts\/20558\/revisions\/32941"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/media\/20559"}],"wp:attachment":[{"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/media?parent=20558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/categories?post=20558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/tags?post=20558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}