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?
With Xcode 9, Look at LocalAuthentication -> LAContext -> LABiometryType.
LABiometryType is a enum with values as in attached image
You can check which authentication type supported by device between Touch ID and FaceID or none.
Edit:
Apple have updated values for this enum LABiometryType. none is deprecated now.
Extension to check supported Biometric Type with Swift 5:
import LocalAuthentication
extension LAContext {
enum BiometricType: String {
case none
case touchID
case faceID
}
var biometricType: BiometricType {
var error: NSError?
guard self.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
return .none
}
if #available(iOS 11.0, *) {
switch self.biometryType {
case .none:
return .none
case .touchID:
return .touchID
case .faceID:
return .faceID
@unknown default:
#warning("Handle new Biometric type")
}
}
return self.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) ? .touchID : .none
}
}