如何在应用程序级别处理Touch ID错误?

时间:2019-05-18 07:04:36

标签: swift touch-id localauthentication

我是iOS Swift的新手。我正在使用本地身份验证框架来实现Touch ID。我希望对userFallback之类的错误进行一些自定义设置以打开密码视图,touchIDLockout错误应用上会显示锁定消息。我需要对无法通过Touch ID进行身份验证的用户进行一些自定义。

下面是处理这些错误的函数,我只需要对其进行一些自定义即可。

func evaluatePolicyFailErrorMessageForLA(errorCode: Int) -> String {
        var message = ""
        if #available(iOS 11.0, macOS 10.13, *) {
            switch errorCode {
            case LAError.biometryNotAvailable.rawValue:
                message = "Authentication could not start because the device does not support biometric authentication."

            case LAError.biometryLockout.rawValue:
                message = "Authentication could not continue because the user has been locked out of biometric authentication, due to failing authentication too many times."

            case LAError.biometryNotEnrolled.rawValue:
                message = "Authentication could not start because the user has not enrolled in biometric authentication."

            default:
                message = "Did not find error code on LAError object"
            }
        } else {
            switch errorCode {
            case LAError.touchIDLockout.rawValue:
                message = "Too many failed attempts."

            case LAError.touchIDNotAvailable.rawValue:
                message = "TouchID is not available on the device"

            case LAError.touchIDNotEnrolled.rawValue:
                message = "TouchID is not enrolled on the device"

            default:
                message = "Did not find error code on LAError object"
            }
        }

        return message;
    }

0 个答案:

没有答案