我想捕获由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)
}
})
}
}