首页 > 解决方案 > 选择认证类型的条件不起作用

问题描述

我无法获得有关使用此代码支持任何类型身份验证的价值:

import SwiftUI
import LocalAuthentication

struct SecurityOption: View {

    let context = LAContext()
    var body: some View {
        Form {
            if (context.biometryType == .faceID) {
                Section(header:  ){
                    }
                }
            }
            if (context.biometryType == .touchID) {
                Section(header:  ){
                    }
                }
            }
            if (context.biometryType == .none) {

            }

我想根据设备上的身份验证类型在表单中显示特定部分,但 .none 会不断触发。在带有 iOS 13.2 的真实 iPhone X 上测试

标签: swiftuixcode11localauthentication

解决方案


您必须NSFaceIDUsageDescription在应用程序Info.plist文件中包含密钥才能使用生物特征验证。


推荐阅读