如何调用警报以访问FaceID / TouchID Swift

问题描述 投票:1回答:1

[我想知道如何调用iOS来显示从苹果弹出的警报,以使用户在应用程序设置中将其禁用时可以使用Face ID / Touch ID进行访问。我知道这已放入info plist中,但是当我从设置中禁用它们时,它不再显示询问:Here is the image from disable

ios swift xcode
1个回答
-1
投票

您需要检查设备是否可以通过生物识别技术进行身份验证。

让我们先执行此操作,然后再调用函数进行身份验证。

func canAuthenByBioMetrics() -> Bool {
    let context = LAContext()
    var authError: NSError?

    if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) {
        return true
    } else {
        return false
    }
}

显示您的代码将类似于:

if self.canAuthenByBioMetrics() {
    // Do you authentication
} else {
    // Ask user for enable permission or setup biometric if needed
}
© www.soinside.com 2019 - 2024. All rights reserved.