Face ID and Touch ID Biometric Authentication
Add additional security to your iOS app
In this Swift tutorial, I will be explaining how you can add Face ID and Touch ID Authentication for securing your user's data. As you already know, the Face ID technology was introduced together with the release of iPhone X, and Touch ID came with the iPhone 5s and is still available in the latest iPhone 8.
The LocalAuthentication framework enables us to request authentication from users through passphrases or biometrics. Because you can't have both Face ID and Touch ID on a single device, Apple has kept everything under one simple method.
All you need to do is
import LocalAuthentication and then copy the following code where you need it.
As I have mentioned earlier, the
canEvaluatePolicy method will detect the biometrics support on the device, and present the correct Authentication feature. This kind of authentication is mostly wanted for apps that contain payments features, files storage, finances and any other kind of sensitive data.
Testing on iOS Simulator
If you have wondered how to test this feature if you don't have a physical device such as the iPhone X or iPhone 5s and later, don't worry. The iOS Simulator provides us with a feature that can bypass this kind of behavior.
Click on your Simulator and then go Hardware -> Touch ID or FaceID from the top menu bar.
In the submenu there will be 3 options available:
- Enrolled - enables the Touch ID or Face ID feature
- Matching Touch - successful authentication
- Non-matching Touch - authentication failed
That’s it from this tutorial and if it helped you please 👏 or share this story so others like you can find it. Thank you for your attention! 🚀
Check out my latest project:
HOT ODDS Each day, we generate a list of the hottest odds in the world. These are odds that have dropped the most…apple.co
Read more of my writing on Medium:
Many iOS apps use Google Maps. This is a very common feature, so I have decided to prepare an ultimate guide on the…medium.freecodecamp.org
Custom UIView with XIB file is a very common practice in iOS Development. Custom UIView classes don’t contain XIB files…medium.com
A Swift tutorial that will make your app available in Spotlight searchhackernoon.com