Search
Thursday 21 March 2019
  • :
  • :

TouchID Authentication in iOS

This post is shared by iOS developers India who tell you the best way to integrate TouchID authentication or password less authentication into your iPad or iPhone application. Learn from this tutorial and share your experience at the end in comments.

One liner: In this tutorial we will learn about how to integrate touchID authentication or password less authentication into your iPhone or iPad application.

touchid

Start with creating one single view application with name “TouchIDDemo”. Select swift as development language and make it universal. Add LocalAuthentication.framework after creating project.

Open Main.storyboard file and add one button in middle of the main view and set title “Authentication”. Add one navigation controller with storyboard entry point and connect with main view as a “root view controller”. Please check below screenshot for more info.

In ViewController.swift file, import LocalAuthentication framework.  Create IBAction method btnAuthenticationClick that is connected with Authentication button. In this method first we need to create an instance of the LAContext class. As all devices do not support TouchID sensor so we need to check that a fingerprint sensor is available on device or not, for that we call canEvaluatePolicy() method. If device has no TouchID sensor than show appropriate error alert. If the device has a TouchID sensor, we show user typical TouchID form.

Next method is with three argument like evaluatePolicy:localizedReason:reply(). In this method we get whether fingerprint is recognized or not. Please check below screenshot for more info.

Add a method named showAlertWithTitle() for showing alert messages to user in case of error.

Add a method named errorMessageForLAErrorCode() for returning error message using error code we receive in reply method by comparing the error code with LAError class. Please check below screenshot for more info.

Build and run project. If everything is correct, your app will let you authenticate using touchID.

iOS developers India have just shared the method to integrate TouchID authentication or password less authentication into your iPad or iPhone application. At any point, you feel to ask the experts, make comments below.



Vijay is a compulsive blogger who likes to educate like-minded people on various new technologies and trends. He works with Aegis SoftTech as a software developer and has been developing software for years. Stay Connected to him on Facebook and Google+.