是否有可能将Apple的Face ID技术用于应用程序



假设我想创建一个带有人脸识别功能的门锁。为了解锁门,我手机上的锁应用程序必须识别我的脸。是否可以使用Apple的Face ID进行身份验证?

您可以使用本地身份验证框架启动 FaceID(如果设备支持 FaceID(并进行身份验证,然后使用该结果。

public func loginWithLocalAuthentication(isLoggedIn : @escaping ((Bool)->Void))
{
let reason = "Log in to your account"
let context = LAContext()
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, error in
if success {
// Move to the main thread because a state update triggers UI changes.
isLoggedIn(true)
} else {
print(error?.localizedDescription ?? "Failed to authenticate")
isLoggedIn(false)
}
}
}

相关内容

最新更新