Advertisement
Guest User

Touch-ID authentication

a guest
Aug 25th, 2016
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.82 KB | None | 0 0
  1. let touchIDContext = LAContext()
  2. var touchIDError : NSError?
  3. let reasonString = "Too much control for more then one person"
  4.  
  5. // Check if we can access local device authentication
  6. if touchIDContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error:&touchIDError) {
  7.         // Initiate authentication
  8.         touchIDContext.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason: reasonString, reply: {
  9.                 (success: Bool, error: Error?) -> Void in
  10.                 // Check if authentication was successful
  11.                 if success {
  12.                         // Do something after authentication
  13.                         userAuthenticated()
  14.                 }
  15.         } )
  16. } else {
  17.         // No Touch-ID sensor, proceed to manual PIN entry
  18.         initPinAuth()
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement