@capgo/capacitor-native-biometric 사용하기
이 플러그인은 Android와 iOS의 네이티브 생체 인증 API에 접근할 수 있게 해줍니다.
호환성
플러그인 메이저 버전은 Capacitor를 따릅니다: Capacitor 8(활발히 유지 관리됨)에는 v8을, Capacitor 7(요청 시 유지 관리됨)에는 v7을 사용하세요. 자세한 내용은 다음 호환성 표.
설치
# Capacitor 8
bun add @capgo/capacitor-native-biometric@8
# Capacitor 7
bun add @capgo/capacitor-native-biometric@7
bunx cap sync
bunx cap sync 플러그인의 네이티브 code를 네이티브 프로젝트에 복사합니다. 플러그인을 업그레이드할 때마다 다시 실행하세요.
가져오기
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
API 한눈에 보기
| 메서드 | 설명 |
|---|---|
isAvailable |
생체 인증 하드웨어 사용 가능 여부를 확인합니다. |
verifyIdentity |
사용자에게 생체 인증을 요청합니다. |
getCredentials |
지정된 서버의 저장된 인증 정보를 가져옵니다. |
setCredentials |
지정된 서버의 인증 정보를 저장합니다. |
deleteCredentials |
지정된 서버의 저장된 인증 정보를 삭제합니다. |
getSecureCredentials |
지정된 서버에 저장된 자격 증명을 생체 인증을 통해 가져옵니다. 자격 증명은 accessControl이 BIOMETRY_CURRENT_SET 또는 BIOMETRY_ANY로 설정된 상태로 저장되어 있어야 합니다. |
isCredentialsSaved |
지정된 서버에 대한 인증 정보가 이미 저장되어 있는지 확인합니다. |
setData |
주어진 키 아래 임의의 문자열 값을 저장합니다. 값은 플랫폼의 보안 저장소 백엔드(Android Keystore + SharedPreferences, iOS Keychain)를 사용하여 저장 시 암호화됩니다. |
getData |
지정된 키에 대해 이전에 저장된 값을 가져옵니다. 생체 인증 없이 저장된 값만 반환합니다. accessControl. |
getSecureData |
지정된 키에 대해 생체 인증으로 보호된 값을 가져옵니다. 값은 다음으로 저장되었어야 합니다. accessControl BIOMETRY_CURRENT_SET 또는 BIOMETRY_ANY로 설정되어 있어야 합니다. |
deleteData |
지정된 키에 대해 저장된 값을 삭제합니다(보호된 값과 보호되지 않은 값 모두). |
isDataSaved |
지정된 키에 대해 값이 이미 저장되어 있는지 확인합니다. |
예시
isAvailable()
생체 인증 하드웨어 사용 가능 여부를 확인합니다.
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
const result = await NativeBiometric.isAvailable();
console.log(result);
verifyIdentity()
사용자에게 생체 인증을 요청합니다.
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
await NativeBiometric.verifyIdentity();
getCredentials()
지정된 서버의 저장된 인증 정보를 가져옵니다.
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
const result = await NativeBiometric.getCredentials({ server: 'example.com' });
// The result holds sensitive values: use it without logging it.
setCredentials()
지정된 서버의 인증 정보를 저장합니다.
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
await NativeBiometric.setCredentials({
username: 'username',
password: 'password',
server: 'example.com',
});
deleteCredentials()
지정된 서버의 저장된 인증 정보를 삭제합니다.
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
await NativeBiometric.deleteCredentials({ server: 'example.com' });
getSecureCredentials()
지정된 서버에 저장된 자격 증명을 생체 인증을 통해 가져옵니다. 자격 증명은 accessControl이 BIOMETRY_CURRENT_SET 또는 BIOMETRY_ANY로 설정된 상태로 저장되어 있어야 합니다.
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
const result = await NativeBiometric.getSecureCredentials({ server: 'example.com' });
// The result holds sensitive values: use it without logging it.
위 표에는 12개의 핵심 메서드가 나열되어 있습니다. Listener와 version 헬퍼, 각 메서드의 전체 계약은 다음 문서에 설명되어 있습니다: GitHub 리포지토리.
이벤트 수신
addListener 핸들을 반환합니다. 호출하세요 handle.remove() 화면이 언마운트될 때.
전체 레퍼런스
@capgo/capacitor-native-biometric 사용하기부터 계속하기
사용 중이라면 @capgo/capacitor-native-biometric 사용하기 인증 및 계정 흐름을 설계할 때, 이를 다음 항목과 연결하세요: @capgo/capacitor-native-biometric @capgo/capacitor-native-biometric의 구현 세부 사항은, 시작하기 Getting Started의 구현 상세 내용은 @capgo/capacitor-social-login @capgo/capacitor-social-login의 구현 세부 사항은, @capgo/capacitor-passkey @capgo/capacitor-passkey의 구현 세부 사항과 2단계 인증 2단계 인증의 구현 세부 사항에 대해서는