시작하기
이 플러그인에 대한 설치 단계와 전체 마크다운 가이드를 포함한 설정 프롬프트 복사하기.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-nfc`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/nfc/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
설치
설치 제목bun add @capgo/capacitor-nfcbunx cap sync수입
수입 제목import { CapacitorNfc } from '@capgo/capacitor-nfc';API 개요
제목 "API 개요"startScanning
제목 "startScanning"NFC 태그를 감지하기 시작합니다.
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.startScanning();stopScanning
제목 "stopScanning"진행 중인 NFC 스캔 세션을 중지합니다.
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.stopScanning();write
제목 "write"제공된 NDEF 레코드를 마지막으로 발견된 태그에 씁니다.
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.write({} as WriteTagOptions);erase
Section titled “삭제”마지막으로 발견된 태그를 삭제하기 위해 빈 NDEF 메시지를 쓰려고 시도합니다.
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.erase();makeReadOnly
Section titled “읽기 전용으로 만들기”마지막으로 발견된 태그를 읽기 전용으로 만드는 것을 시도합니다.
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.makeReadOnly();다른 기기와의 페어링을 통해 NDEF 메시지를 공유합니다 (안드로이드 전용).
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.share({} as ShareTagOptions);unshare
Section titled “공유 중지하기”이전으로 제공된 NDEF 메시지를 공유 중지합니다 (안드로이드 전용).
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.unshare();getStatus
getStatus현재 NFC 어댑터 상태를 반환합니다.
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.getStatus();showSettings
설정시스템 설정 페이지를 열어 NFC를 활성화할 수 있는지 확인합니다.
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.showSettings();isSupported
NFC 하드웨어 지원 여부를 확인합니다.반환
장치에 NFC 하드웨어가 존재하면 NFC가 현재 활성화되어 있거나 비활성화되어 있지 않음에 관계없이 true를 반환합니다. true 장치에 NFC 하드웨어가 존재하지 않으면 false를 반환합니다. false 이 메서드를 사용하여 NFC 기능이 표시되는 앱 UI에서 NFC 기능을 표시할지 여부를 결정할 수 있습니다.
NFC가 현재 활성화되어 있는지 확인하려면 다른 메서드를 사용하세요. getStatus().
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.isSupported();타입 참조
타입 참조StartScanningOptions
스캔 옵션스캔 옵션
export interface StartScanningOptions { /** * iOS-only: closes the NFC session automatically after the first successful tag read. * Defaults to `true`. */ invalidateAfterFirstRead?: boolean; /** * iOS-only: custom message displayed in the NFC system sheet while scanning. */ alertMessage?: string; /** * iOS-only: session type to use for NFC scanning. * - `'ndef'`: Uses NFCNDEFReaderSession (default). Only detects NDEF-formatted tags. * - `'tag'`: Uses NFCTagReaderSession. Detects both NDEF and non-NDEF tags (e.g., raw MIFARE tags). * Allows reading UID from unformatted tags. * **Requires** the `Near Field Communication Tag Reader Session Formats` entitlement * in your app with the `TAG` format included. Without it the session will fail to * start and the promise will reject with a `NO_NFC` error code. * Defaults to `'ndef'` for backward compatibility. */ iosSessionType?: 'ndef' | 'tag'; /** * Android-only: raw flags passed to `NfcAdapter.enableReaderMode`. * Defaults to enabling all tag types with skipping NDEF checks. */ androidReaderModeFlags?: number;}WriteTagOptions
태그 쓰기 옵션태그 공유 옵션
export interface WriteTagOptions { /** * Array of records that compose the NDEF message to be written. */ records: NdefRecord[]; /** * When `true`, the plugin attempts to format NDEF-formattable tags before writing. * Defaults to `true`. */ allowFormat?: boolean;}ShareTagOptions
복사태그 공유 옵션
export interface ShareTagOptions { records: NdefRecord[];}NfcStatus
NfcStatusNFC 어댑터 상태를 반환하는 .
export type NfcStatus = 'NFC_OK' | 'NO_NFC' | 'NFC_DISABLED' | 'NDEF_PUSH_DISABLED';NfcEvent
NfcEventNFC 디스커버리 이벤트를 디스패치하는 플러그인.
export interface NfcEvent { type: NfcEventType; tag: NfcTag;}NfcStateChangeEvent
NfcStateChangeEventNFC 어댑터 가용성 변경 이벤트.
export interface NfcStateChangeEvent { status: NfcStatus; enabled: boolean;}NdefRecord
NdefRecordNDEF 레코드를 나타내는 JSON 구조.
export interface NdefRecord { /** * Type Name Format identifier. */ tnf: number; /** * Type field expressed as an array of byte values. */ type: number[]; /** * Record identifier expressed as an array of byte values. */ id: number[]; /** * Raw payload expressed as an array of byte values. */ payload: number[];}NfcEventType
NfcEventTypeNFC 이벤트 유형
export type NfcEventType = 'tag' | 'ndef' | 'ndef-mime' | 'ndef-formatable';NfcTag
NfcTagNFC 태그 정보
export interface NfcTag { /** * Raw identifier bytes for the tag. */ id?: number[]; /** * List of Android tech strings (e.g. `android.nfc.tech.Ndef`). */ techTypes?: string[]; /** * Human readable tag type when available (e.g. `NFC Forum Type 2`, `MIFARE Ultralight`). */ type?: string | null; /** * Maximum writable size in bytes for tags that expose NDEF information. */ maxSize?: number | null; /** * Indicates whether the tag can be written to. */ isWritable?: boolean | null; /** * Indicates whether the tag can be permanently locked. */ canMakeReadOnly?: boolean | null; /** * Array of NDEF records discovered on the tag. */ ndefMessage?: NdefRecord[] | null;}진실의 근원
진실의 근원이 페이지는 플러그인의 데이터를 사용하여 생성되었습니다. src/definitions.ts업스트림에서 pubic API이 변경되면 다시 싱크를 실행하세요.