I am using touch id with my iOS 11 app and I am using LA to determine if authentication failed, user cancels and usefallback like so:
import Foundation
import LocalAuthentication
class TouchIDAuth {
let context = LAContext()
func canEvaluatePolicy() -> Bool {
return context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil)
}
func authenticateUser(completion: @escaping (NSNumber?) -> Void) {
guard canEvaluatePolicy() else {
completion(0)
return
}
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics,
localizedReason: "Logging in with Touch ID") { (success, evaluateError) in
if success {
DispatchQueue.main.async {
completion(nil)
}
} else {
let response: NSNumber
switch evaluateError {
case LAError.authenticationFailed?:
response = 2
case LAError.userCancel?:
response = 3
case LAError.userFallback?:
response = 4
default:
response = 1
}
completion(response)
}
}
}
}
The code above works, but I am getting these warnings:
'touchIDLockout' was deprecated in iOS 11.0: use LAErrorBiometryLockout
'touchIDNotEnrolled' was deprecated in iOS 11.0: use LAErrorBiometryNotEnrolled
'touchIDNotAvailable' was deprecated in iOS 11.0: use LAErrorBiometryNotAvailable
Now I know these are coming from LAError, my question is, how do I update my switch case statement to check for authentication failed, user cancels and usefallback?