我想在 iOS 中捕获 Face ID Biometrics 拍摄的用户照片。
但是,iOS Biometrics 不会返回图像数据。它只返回成功或错误作为结果。
我的主要想法是拍摄用户的照片并利用 iPhone 的功能来验证照片是真实的人而不是被欺骗的照片。
iPhone 正在使用摄像头、红外线和点式投影仪来验证真人是否在摄像头前面。
然后我想把这张照片上传到我们的服务器。
func authenticate(completion: @escaping ((Bool) -> ())){
let authenticationContext = LAContext()
var error:NSError?
let isValidSensor : Bool = authenticationContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
if isValidSensor {
authenticationContext.evaluatePolicy(
.deviceOwnerAuthenticationWithBiometrics,
localizedReason: "Touch / Face ID authentication",
reply: { (success, error) -> Void in
if(success) {
completion(true)
} else {
completion(false)
}
})
}
}