#import "ViewController.h"
#import <LocalAuthentication/LocalAuthentication.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
LAContext *contex = [[LAContextalloc]init];
BOOL isCan = [contexcanEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationerror:nil];
//因为有的设备没有指纹识别
if (isCan) {
[contex evaluatePolicy:LAPolicyDeviceOwnerAuthenticationlocalizedReason:@"识别验证打开支付宝!"reply:^(BOOL success,NSError * _Nullable error) {
if (success) {
NSLog(@"识别成功!!!!");
}else{
if (error.code ==kLAErrorUserFallback) {
NSLog(@"用户点击了输入密码!");
}
if (error.code ==kLAErrorUserCancel) {
NSLog(@"用户点击了取消!");
}
}
}];
}else{
NSLog(@"不支持");
}
}
@end