let context = LAContext()
context.localizedFallbackTitle = "Fall back button"
if #available(iOS 10.0, *) {
context.localizedCancelTitle = "Cancel button"
}
var authError: NSError?
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) {
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: "Localized reason for authentication with biometrics", reply: { (success, evaluateError) in
// NOT in main thread
DispatchQueue.main.async {
if success {
self.label.text = "Success"
// Do something success
} else if let error = evaluateError {
self.label.text = error.localizedDescription
// Deal with error
if let code = LAError.Code(rawValue: (error as NSError).code) {
switch code {
case .userFallback:
print("fall back button clicked")
default:
break
}
}
}
}
})
} else if let error = authError {
label.text = error.localizedDescription
// Deal with error
}
if #available(iOS 9.0, *) {
let context = LAContext()
context.localizedFallbackTitle = "Fall back button"
if #available(iOS 10.0, *) {
context.localizedCancelTitle = "Cancel button"
}
var authError: NSError?
if context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &authError) {
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Localized reason for authentication", reply: { (success, evaluateError) in
// NOT in main thread
DispatchQueue.main.async {
if success {
self.label.text = "Success"
// Do something success
} else if let error = evaluateError {
self.label.text = error.localizedDescription
// When fall back button clicked, user is required to enter PIN. Error code will not be "userFallback"
// Deal with error
}
}
})
} else if let error = authError {
label.text = error.localizedDescription
// Deal with error
}
} else {
let alert = UIAlertController(title: nil, message: "Authentication is available on iOS 9.0 or later", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
present(alert, animated: true, completion: nil)
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有