title: How to get a callback every time faceid/touchid authentication fails
body: <p>We have a requirement where we have to block the user for 24 hours if Face ID or Touch ID fails for 5 consecutive time. </p>
  
  <p>In Face ID, I am using the fallback to call authentication manager again, and after total of 6 attempts (2 in each call), I block the user in the fallback method itself.</p>
  
  <p>In Touch ID, on third failure, I get a call back to Authentication failed. I call authentication manager again, and on 5th try, I get a call back to Lockout in which I can block the user. </p>
  
  <p>Is there any way common in both Face ID and Touch ID where I can get a callback after every single individual failure so that I can block the user on 5th failure itself?</p>
  
  <pre><code>//MARK:- Check if user has valid biometry, if yes, validate, else, show error
  fileprivate func biometricAuthentication(completion: @escaping ((Bool) -&gt; ())){
      //        addBlurredBackground()
      //Check if device have Biometric sensor
      if biometryRetryCount == 2 {
          authenticationContext.localizedFallbackTitle = "Ok"
      } else {
          authenticationContext.localizedFallbackTitle = "Retry"
      }
  
      let isValidSensor : Bool = authenticationContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &amp;error)
  
      if isValidSensor {
          //Device have BiometricSensor
          authenticationContext.evaluatePolicy(
              .deviceOwnerAuthenticationWithBiometrics,
              localizedReason:  biometryRetryCount == 2 ? "You have been blocked from using the application for next 24 hours. Please come back later" : "Touch / Face ID authentication",
              reply: { [unowned self] (success, error) -&gt; Void in
  
                  if(success) {
                      // Touch or Face ID recognized
                      //                        self.removeBlurredBackground()
                      completion(true)
                  } else {
                      //If not recognized then
                      if let error = error {
                          let msgAndAction = self.errorMessage(errorCode: error._code)
                          if msgAndAction.0 != "" {
                              UIApplication.topViewController()?.showAlert(withTitle: "Error", andMessage: msgAndAction.0, andActions: msgAndAction.1)
                          }
                      }
                      completion(false)
                  }
          })
      } else {
          let msgAndAction = self.errorMessage(errorCode: (error?._code)!)
          if msgAndAction.0 != ""{
              UIApplication.topViewController()?.showAlert(withTitle: "Error", andMessage: msgAndAction.0, andActions: msgAndAction.1)
          }
      }
  
  }
  </code></pre>
  
  <p>The error methods:</p>
  
  <pre><code>//MARK: TouchID error
  fileprivate func errorMessage(errorCode:Int) -&gt; (strMessage: String, action: [UIAlertAction]){
  
      var strMessage = ""
      let cancelAction = UIAlertAction.init(title:  Const.Localize.Common().kCancel, style: .cancel) { (cancelAction) in
      }
      var actions: [UIAlertAction] = [cancelAction]
  
      switch errorCode {
  
      case LAError.Code.authenticationFailed.rawValue:
          biometricAuthentication { (success) in
              //
          }
      case LAError.Code.userCancel.rawValue:
          if biometryRetryCount == 2 {
              blockUserFor24Hours()
          } else {
              showAlertOnCancelTapAction()
          }
      case LAError.Code.passcodeNotSet.rawValue:
          strMessage = "Please goto the Settings &amp; Turn On Passcode"
      case LAError.Code.userFallback.rawValue:
          biometryRetryCount -= 2
          if biometryRetryCount == 0 {
              blockUserFor24Hours()
          } else {
              biometricAuthentication { (success) in
                  //
              }
          }
      default:
          strMessage = evaluatePolicyFailErrorMessageForLA(errorCode: errorCode).strMessage
          actions = evaluatePolicyFailErrorMessageForLA(errorCode: errorCode).action
      }
  
      return (strMessage, actions)
  }
  
  
  func evaluatePolicyFailErrorMessageForLA(errorCode: Int) -&gt; (strMessage: String, action: [UIAlertAction]){
      let cancelAction = UIAlertAction.init(title:  Const.Localize.Common().kCancel, style: .cancel) { (cancelAction) in
      }
      var actions: [UIAlertAction] = [cancelAction]
  
      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:
              showPasscodeScreen()
  
          case LAError.biometryNotEnrolled.rawValue:
              message = "You do not have a registered biometric authentication. Kindly go to the settings and setup one"
              let settingsAction = UIAlertAction.init(title:  Const.Localize.Common().kSetting, style: .default) { (settingsAction) in
                  UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!)
              }
              actions.append(settingsAction)
  
          default:
              message = "Did not find error code on LAError object"
          }
      } else {
          switch errorCode {
          case LAError.touchIDLockout.rawValue:
              showPasscodeScreen()
          case LAError.touchIDNotAvailable.rawValue:
              message = "TouchID is not available on the device"
          case LAError.touchIDNotEnrolled.rawValue:
              message = "You do not have a registered biometric authentication. Kindly go to the settings and setup one"
              let settingsAction = UIAlertAction.init(title:  Const.Localize.Common().kSetting, style: .default) { (settingsAction) in
                  UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!)
              }
              actions.append(settingsAction)
  
          default:
              message = "Did not find error code on LAError object"
          }
      }
  
      return (message, actions)
  }
  </code></pre>