iPhone 생체인증(Biometrics) 지원여부 확인

2021. 3. 12. 11:32개발자료/iOS


반응형

## 생체인증(Biometrics) 지원여부

- (BOOL) isSupportBiometric {
    if (![LAContext class]) {
        return NO;
    }
    
    LAContext *laContext = [[LAContext alloc] init];
    NSError *error = nil;
    if (![laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
        return NO;
    }
    
    return YES;
}

 

## 지문인증(TouchID) 지원여부

- (BOOL) isSupportTouchID {
    if (![LAContext class]){
        return NO;
    }

    LAContext *laContext = [[LAContext alloc] init];
    NSError *error = nil;
    if (![laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
        return NO;
    }

    if (@available(iOS 11.0, *)) {
        if (laContext.biometryType == LABiometryTypeTouchID){
            return YES;
        } else {
            return NO;
        }
    }
    
    return YES;
}

 

## 안면인증(FaceID) 지원여부

- (BOOL) isSupportFaceID {
    if (![LAContext class]){
        return NO;
    }
    
    LAContext *laContext = [[LAContext alloc] init];
    NSError *error = nil;
    if (![laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
        return NO;
    }

    if (@available(iOS 11.0, *)) {
        if (laContext.biometryType == LABiometryTypeFaceID){
            return YES;
        } else {
            return NO;
        }
    }
    
    return NO;
}
반응형