iOS touchID 통합

2925 단어
  • 시스템 헤더 파일을 가져옵니다#import
  • 검증이 필요한 위치에서 호출하는 방법
  • LAContext *context = [[LAContext alloc]init];
        NSError *error = nil;
        NSLog(@"%@",[context evaluatedPolicyDomainState]);
        if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) {
          [context evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:@" id" reply:^(BOOL success, NSError * _Nullable error) {
                if (success) {
                    NSLog(@" ");
                } else {
                    NSLog(@"%@",error.localizedDescription);
                    switch (error.code) {
                        case LAErrorSystemCancel:
                        {
                            NSLog(@" , APP ");
                            break;
                        }
                        case LAErrorUserCancel:
                        {
                            NSLog(@" Touch ID");
                            break;
                        }
                        case LAErrorAuthenticationFailed:
                        {
                            NSLog(@" ");
                            break;
                        }
                        case LAErrorPasscodeNotSet:
                        {
                            NSLog(@" ");
                            break;
                        }
                        case LAErrorTouchIDNotAvailable:
                        {
                            NSLog(@" Touch ID , ");
                            break;
                        }
                        case LAErrorTouchIDNotEnrolled:
                        {
                            NSLog(@" Touch ID , ");
                            break;
                        }
                        case LAErrorUserFallback:
                        {
                            [[NSOperationQueue mainQueue] addOperationWithBlock:^{
                                NSLog(@" , ");
                            }];
                            break;
                        }
                        default:
                        {
                            [[NSOperationQueue mainQueue] addOperationWithBlock:^{
                                NSLog(@" , ");
                            }];
                            break;
                        }
                    }
                }
            }];  } else { 
            NSLog(@" ");
            switch (error.code) {
                case LAErrorTouchIDNotEnrolled:
                {
                    NSLog(@"TouchID is not enrolled");
                    break;
                }
                case LAErrorPasscodeNotSet:
                {
                    NSLog(@"A passcode has not been set");
                    break;
                }
                default:
                {
                    NSLog(@"TouchID not available");
                    break;
                }
            }
            NSLog(@"%@",error.localizedDescription);  }
    

    좋은 웹페이지 즐겨찾기