iOS에서 Touch ID(지문인식) 사용하기.
posted on 05 Jul 2017 under category iOS
iOS에서 제공해주는 Touch-ID 간편하게 사용하기
#import <LocalAuthentication/LocalAuthentication.h>
LAContext *context = [[LAContext alloc] init];
NSError *error;
if([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]){
// 성공
}else{
// 실패
}
실패하는 경우
LAContext *context = [[LAContext alloc] init];
NSError *error;
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"지문을 입력해주세요" reply:^(BOOL success, NSError *error){
if(success){
NSLog(@"@@@@성공");
}else{
NSLog(@"@@@@실패");
}
}];
LAContext *context = [[LAContext alloc] init];
NSError *error;
if([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]){
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"지문을 입력해주세요" reply:^(BOOL success, NSError *error){
if(success){
NSLog(@"@@@@성공"); // 지문 인증 성공했을때
}else{
NSLog(@"@@@@실패");
}
}];
}else{
NSLog(@"Touch 지원하지 않음");
}