Apple为iOS 8的TouchID实现提供的文档在Objective-C中.
有Swift版本吗?
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) {
}
}
}
Run Code Online (Sandbox Code Playgroud)
迅速:
@IBAction func touchidbutton(sender: AnyObject) {
authContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Place your finger on the sensor"?, reply: ((success : Bool, NSError!) -> Void)?){
if (success) {
}
}
}
Run Code Online (Sandbox Code Playgroud)