I currently do FaceID validation in my apps but it looks like Apple is offering FaceID ad the App level. Does this mean we still need to or can code for it in iOS 18 apps? Right now I've been working on migrating to iOS 18 using beta but my swift code just returns an "unknown error". From a developer perspective I can't find any examples or guidance on how handle FaceID currently in iOS 18 or going forward.
Anyone have any insights or resources.
This is the code that used to work but now under iOS 18 returns the error. Maybe the simulator and swift have not caught up but I don't think so given that it's been two beta release that I know of where this has not worked.
class biometric {
class func authenticateUser() async -> (Bool, Error?) {
let context = LAContext()
var error: NSError?
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
let biometryType = context.biometryType
var reason = "Authenticate with \(biometryType)"
if biometryType == .faceID {
reason = "Authenticate with Face ID"
} else if biometryType == .touchID {
reason = "Authenticate with Touch ID"
}
do {
let success = try await context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason)
LogEvent.print(module: "Authentication.biometric.authenticateUser", message: "Biometric authentication. success: \"\(success)\".")
return (success, nil)
} catch let evaluationError as LAError {
LogEvent.print(module: "Authentication.biometric.authenticateUser", message: "Biometric authentication failed. evaluationError: \"\(evaluationError.localizedDescription)\"")
handleEvaluationError(evaluationError)
I do get past the .canEvaluatePolicy
but fail on the .evaluatePolicy