This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import LocalAuthentication | |
| /// AuthenticationBlockState | |
| enum AuthenticationBlockState { | |
| case success | |
| case failed | |
| case canceledByUser | |
| case fallback | |
| case canceledBySystem | |
| case passcodeNotSet | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | let kReasonMessage = "Biometeric required your authentication." | |
| /// Biometric Default Reason(s) | |
| let kBiometryNotAvailableReason = "Biometric authentication is not available for this device." | |
| /// Common Message(s) | |
| let kSetPasscode = "Please set device passcode for authentication." | |
| /// TouchID Related Message(s) | |
| let kTouchIdAuthenticationReason = "Confirm your fingerprint to authenticate." | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /// Change default message as per your need. | |
| fileprivate static var defaultReasonMessage: String { | |
| return LocalAuthentication.isFaceIdAvailable ? kFaceIdAuthenticationReason : kTouchIdAuthenticationReason | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /// Variable Declaration(s) | |
| class var isFaceIdAvailable: Bool { | |
| let context: LAContext = LAContext() | |
| let evaluate = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) | |
| if #available(iOS 11.0, *) { | |
| return (context.biometryType == .faceID) | |
| } | |
| return evaluate | |
| } | 
NewerOlder