swift Touch ID 的简单使用 指纹识别

swift Touch ID 的简单使用 指纹识别,第1张

概述上篇记录了 Touch ID 的简单使用方法。 因为最近无聊有在学 swift,顺便写了 swift Touch ID 的 Demo 。 基本上,swift 中使用 Touch ID 和 OC差不多,只是语法稍有改变。 首先初始化上下文 let laContext = LAContext() var error : NSError? //判断是否支持   let bool:Bool =  laCo


上篇记录了 touch ID 的简单使用方法。

因为最近无聊有在学 swift,顺便写了 swift touch ID 的 Demo 。

基本上,swift 中使用 touch ID 和 OC差不多,只是语法稍有改变。

首先初始化上下文

let laContext = LAContext()

var error : NSError?

//判断是否支持

let bool:Bool = laContext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication,error: &error)

与OC一样,参数的值有两种类型,不过要记得使用点语法

//验证指纹

LAPolicy.DeviceOwnerAuthenticationWithBiometrics

//可验证密码

LAPolicy.DeviceOwnerAuthentication

//然后进行验证,参数一样。

if bool{

laContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthentication,localizedReason: "牛逼你就按一下",reply: { (success:Bool,error:NSError?) -> VoID in

print(“牛逼")

})

error类型相同,此处略。

总结

以上是内存溢出为你收集整理的swift Touch ID 的简单使用 指纹识别全部内容,希望文章能够帮你解决swift Touch ID 的简单使用 指纹识别所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1081539.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存