Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 126.96.36.199 release ready!
Owner and Founder. Opencart
Local Authentication is used to authenticate users biometrically or with a passphrase, they already know. It is used to implements biometric authentication like TouchID and FaceID. In this blog, we will see how to add biometrics into the application. So let’s begin.
Firstly we need to import the Local Authentication framework.
Secondly, we need to verify that the device supports FaceID or TouchID. For this, we need to use canEvaluatePolicy() method of the LAContext class. This method accepts the security policy type as an argument. So, You need to pass the security policy type in canEvaluatePolicy() method. There are two types of security policy provided by this framework.
This policy type is used to authenticate using a biometric method (Touch ID or Face ID). If it is not available, not enrolled, or locked out, then the result of this policy will fail with LAErrorBiometryNotAvailable, LAErrorBiometryNotEnrolled, or LAErrorBiometryLockout.
This policy type is used to be authenticated by biometry or device passcode. If it is available, enrolled, and not locked out, users are asked for it first. Else, the device passcode fill option will be shown. If the passcode is not enabled, policy result will fail with LAErrorPasscodeNotSet.
Thirdly and most important you need to request the biometric system to ask the reason for the biometric scan. For TouchID you need to write the string in the code. And for FaceID you need to write the string in Info.Plist file.
Now we need to call the evaluatePolicy() method with the same security policy type and it accept a tailing closure which contains the result of the policy evaluation.
The tailing closure contains 2 parameters, 1st one contains the boolean condition which tells if the login is a success or not. If not successful then the error message will be shown on the 2nd parameter.
Now the only last thing that remains to talk about is &error. The Local Authentication framework uses the Objective-C style for reporting the error, therefore, we need to use NSError for handle error.
Thank you for reading this article. If you want to read more articles regarding iOS Development click here or if you want to know more about Local Authentication then do check out this apple doc.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We've bought a Shopware Extension which is a hybrid App, which we can now offer in the Google Play Store and the IOS App Store. I'am still impressed how fast and how sharp the support team leads us through every process of the App-Store clarification. Very fast and useful response.
Founder, Das Apartment Living
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.