I've integrated LocalAuthentication for my app security purpose, which has been supporting 'Touch Id' based supporting. But now, apple has recently added 'Face Id' based authentication also.
How can I check, which type of authentication is supported by a device. Touch Id or Face Id?
As we said Face ID requires you to have open eyes, while Touch ID only requires a fingerprint. There are good and bad things about this.
It is a method of biometric identification that uses that body measures, in this case, face and head, to verify the identity of a person through its facial biometric pattern and data.
Any app supporting Touch ID will automatically work with Face ID, according to Apple(Opens in a new window). But you'll have to double-check on an individual basis. The app should tell you either directly or somewhere in its settings if it supports Touch ID or Face ID.
On the Login screen, you will have the option to Enable Face ID. If you select the option and confirm the permissions to use this feature, Face ID starts detecting your face. If your face recognition fails, an appropriate message displays.
I've been struggling to get this to work and found that I needed to use a single instance of the LAContext and needed to call the LAContextInstance.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) before getting the biometryType. Here is my final code with support for older iOS versions:
import LocalAuthentication static func biometricType() -> BiometricType { let authContext = LAContext() if #available(iOS 11, *) { let _ = authContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) switch(authContext.biometryType) { case .none: return .none case .touchID: return .touch case .faceID: return .face } } else { return authContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) ? .touch : .none } } enum BiometricType { case none case touch case face }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With