- 功能需求:一些密碼管理,支付寶,銀行軟件,私密日記等只想自己可以打開,而且打開應(yīng)用需要自己指紋;
- 注意:iOS8之前指紋識別是沒有公開給第三方應(yīng)用;
- (void)viewDidLoad {
[super viewDidLoad];
[self evaluatePolicy];
}
- (void)evaluatePolicy
{
//初始化上下文對象
LAContext *context = [[LAContext alloc] init];
//錯誤對象
__block NSString *msg;
NSError *error;
//首先使用判斷設(shè)備支持狀態(tài)
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
//支持指紋驗(yàn)證
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"船長請解鎖", nil) reply:
^(BOOL success, NSError *authenticationError) {
if (success) {
msg =[NSString stringWithFormat:NSLocalizedString(@"EVALUATE_POLICY_SUCCESS", nil)];
} else {
msg = [NSString stringWithFormat:NSLocalizedString(@"EVALUATE_POLICY_WITH_ERROR", nil), authenticationError.localizedDescription];
}
}];
}else{ //不支持指紋識別
NSLog(@"Touch ID is not available%@",error);
}
}
效果圖:
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者