您可以通過使用密碼認證用戶來解鎖生物特徵識別。 只需將此功能粘貼到您的項目中並在使用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
}
但是不知道鎖定後等待解鎖需要多長時間嗎?我的意思是,當你用生物識別技術失敗X次,然後用密碼失敗X次時,iPhone會鎖定這兩種方法,但我無法看到有多少次需要等待解鎖。 –
您不知道手機鎖定的時間。絕對沒有辦法知道這些信息。其次,如果您試圖在您的應用中確定這一點,那麼您可能會以錯誤的方式解決問題。 – Tander