以下代码将在进行身份验证时显示警报。我希望这种身份验证应该在后台进行,就像我们使用touch id解锁iPhone的密码锁一样。
func touchidcheck(){
let authcontext:LAContext=LAContext()
var error:NSError?
if authcontext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &error){
authcontext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Testing", reply: {
(wasSuccessful:Bool, error:NSError?) in
if wasSuccessful{
print("Yes")}
else
{
print("No")
}
}
)
}
}