Import:
import LocalAuthentication
Code:
// 1. Create a authentication context
let authenticationContext = LAContext()
var error:NSError?
// 2. Check if the device has a fingerprint sensor
guard authenticationContext.canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: &error)
else
{
showAlertViewIfNoBiometricSensorHasBeenDetected()
return
}
// 3. Check the fingerprint
authenticationContext.evaluatePolicy(
.DeviceOwnerAuthenticationWithBiometrics,
localizedReason: "Please login using your fingerprint",
reply:
{
[unowned self] (success, error) -> Void in
self.spinner = JHSpinnerView.showDeterminiteSpinnerOnView(self.view)
if( success )
{
}
else // Failure
{
}
})
No comments:
Post a Comment