簡體   English   中英

觸摸ID:鎖定生物測量。 代碼= -8

[英]Touch ID: Biometry is locked out. Code=-8

我使用Touch id識別我的應用程序中的iPhone用戶,何時使用canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics來評估用戶是否有資格使用Touch ID,但是在許多嘗試失敗后,即使用戶有資格使用touch id,它也會返回FALSE

這將導致應用程序跳過此步驟,並認為此設備不支持觸摸ID。

這是我得到的錯誤:

Error Domain = com.apple.LocalAuthentication Code = -8“Biometry被鎖定。” UserInfo = {NSLocalizedDescription = Biometry被鎖定。}

好吧,我認為我找到了答案。 希望它會對你有所幫助。 當你拿到時

Error Domain=com.apple.LocalAuthentication Code=-8 "Biometry is locked out." UserInfo={NSLocalizedDescription=Biometry is locked out.}

iOS 10阻止訪問TouchID,它可以通過在iOS解鎖屏幕上提供密碼,訪問TouchID iOS設置並在那里提供密碼或從應用程序內手動觸發密碼屏幕來解鎖。 您可以使用以下代碼段打開密碼屏幕。

let context = LAContext()
context.evaluatePolicy(LAPolicy.DeviceOwnerAuthentication,
                           localizedReason: reason,
                           reply: { (success, error) in
})

當然,您可以先檢查是否可以評估此​​政策。

因此,最后,當用戶成功輸入密碼時,生物測定將被解鎖。 在iOS 10之前,這是由操作系統自動完成的。

您可以通過使用密碼驗證用戶來解鎖生物測定。 只需將此功能粘貼到項目中,然后在使用Touch ID對用戶進行身份驗證之前調用此函數。

如果它返回true運行Touch ID身份驗證,如果由於生物測定鎖定而失敗,則會要求用戶輸入iPhone密碼以解鎖生物測定。 這將在應用程序內發生。

func isBiometryReady() -> Bool
{
        let context : LAContext = LAContext();
                var error : NSError?

            context.localizedFallbackTitle = ""
            context.localizedCancelTitle = "Enter Using Passcode"

            if (context.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error))
            {
                    return true
            }

            if error?.code == -8
            {
                let reason:String = "TouchID has been locked out due to few fail attemp. Enter iPhone passcode to enable TouchID.";
                context.evaluatePolicy(LAPolicy.deviceOwnerAuthentication,
                                       localizedReason: reason,
                                       reply: { (success, error) in

                                        return false

                })

                return true


            }

    return false
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM