如何在Xamarin中处理iOS生物识别身份验证中的错误案例?

时间:2018-06-04 05:02:17

标签: ios xamarin xamarin.ios fingerprint localauthentication

/test

我想根据错误类型处理else条件中的错误情况。

1 个答案:

答案 0 :(得分:2)

您可以从返回的NSError获取失败代码,并根据LAStatus代码对其进行处理:

switch (error.Code)
{
    case (long)LAStatus.AuthenticationFailed:
        ~~~
        break;
    case (long)LAStatus.UserCancel:
        ~~~
        break;
    ~~~
    default:
        break;
}

LAStatus(删除了弃用):

public enum LAStatus : long
{
    Success,
    AuthenticationFailed = -1L,
    UserCancel = -2L,
    UserFallback = -3L,
    SystemCancel = -4L,
    PasscodeNotSet = -5L,
    AppCancel = -9L,
    InvalidContext = -10L,
    BiometryNotAvailable = -6L,
    BiometryNotEnrolled = -7L,
    BiometryLockout = -8L,
    NotInteractive = -1004L
}

有关各种代码的描述,可以使用LAError.Code: