【问题标题】:Would it be possible to use Apple’s Face ID technology for an app是否可以将 Apple 的 Face ID 技术用于应用程序
【发布时间】:2020-05-26 11:37:46
【问题描述】:

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

【问题讨论】:

  • 是的,您可以使用 LocalAuthentication 框架来启动 FaceID(如果设备支持 FaceID)并进行身份验证并将结果发送到您的锁以解锁或锁定门。

标签: ios face-recognition face


【解决方案1】:

您可以使用 LocalAuthentication 框架来启动 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)
        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多