如何使用Swift使用TouchID? [英] How to use TouchID using Swift?

查看:177
本文介绍了如何使用Swift使用TouchID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple为iOS 8的TouchID实现提供的文档在Objective-C中。

The documentation that Apple has provided for TouchID implementation for iOS 8 is in Objective-C.

是否有Swift版本?

Is there a Swift version of it?

Objective-C:

Objective-C:

- (IBAction)touchIDAvailable:(UIButton *)touchIDAvailableButton {
    LAContext *context = [[LAContext alloc] init];
    __block  NSString *msg;
    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"Place your finger on the sensor", nil) reply: ^(BOOL success, NSError *authenticationError) {
         if (success) {
         }
    }
}

Swift:

@IBAction func touchidbutton(sender: AnyObject) {
    authContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Place your finger on the sensor"?, reply: ((success : Bool, NSError!) -> Void)?){
        if (success) {
        }
    }
}


推荐答案

找到它!

以下链接来自Github的名为Shmoopi的用户。 Shmoopi让应用程序测试Swift编程的TouchID。

The link below is from a user named Shmoopi from Github. Shmoopi made the app to test the TouchID programmed in Swift.

https://github.com/Shmoopi/Swift-Touch-ID

这篇关于如何使用Swift使用TouchID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆