Getting Started
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함한 설정 명령어를 복사하세요.
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
__CAPGO_KEEP_0__ 시작 스캔NFC 태그를 듣기 시작합니다.
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.startScanning();stopScanning
__CAPGO_KEEP_0____CAPGO_KEEP_1__
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.stopScanning();write
__CAPGO_KEEP_3____CAPGO_KEEP_4__
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.write({} as WriteTagOptions);erase
__CAPGO_KEEP_6____CAPGO_KEEP_7__
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.erase();makeReadOnly
__CAPGO_KEEP_9____CAPGO_KEEP_10__
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.makeReadOnly();share
공유다른 기기와 NFC로 연결하여 NDEF 메시지를 공유합니다 (안드로이드만).
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.share({} as ShareTagOptions);unshare
공유 중지이전으로 제공된 NDEF 메시지를 중지합니다 (안드로이드만).
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.unshare();getStatus
NFC 어댑터 상태를 가져옵니다.클립보드에 복사
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.getStatus();showSettings
클립보드에 복사NFC를 사용할 수 있는 시스템 설정 페이지를 엽니다.
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.showSettings();isSupported
isSupported장치가 NFC 하드웨어 지원을 가지고 있는지 확인합니다.
반환 true 장치에 NFC 하드웨어가 있는 경우, NFC가 현재 활성화되거나 비활성화되어도 반환합니다. 장치에 NFC 하드웨어가 없는 경우 반환 false 장치에 NFC 하드웨어가 없을 때 반환
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
__CAPGO_KEEP_0____CAPGO_KEEP_1__
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
__CAPGO_KEEP_3____CAPGO_KEEP_4__
export interface ShareTagOptions { records: NdefRecord[];}NfcStatus
__CAPGO_KEEP_6____CAPGO_KEEP_7__
export type NfcStatus = 'NFC_OK' | 'NO_NFC' | 'NFC_DISABLED' | 'NDEF_PUSH_DISABLED';NfcEvent
__CAPGO_KEEP_9____CAPGO_KEEP_10__
export interface NfcEvent { type: NfcEventType; tag: NfcTag;}NfcStateChangeEvent
NfcStateChangeEvent 섹션NFC 어댑터 가용성 변경 시 발생하는 이벤트.
export interface NfcStateChangeEvent { status: NfcStatus; enabled: boolean;}NdefRecord
NdefRecord 섹션NDEF 레코드를 나타내는 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
NfcEventType 섹션NFC 발견 유형을 설명하는 이벤트.
export type NfcEventType = 'tag' | 'ndef' | 'ndef-mime' | 'ndef-formatable';NfcTag
NfcTag 섹션자연어 층에서 반환된 전체 태그 정보를 나타내는 표현.
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. 업스트림의 공공 API이 변경될 때 다시 싱크를 실행하세요.
시작하기
시작하기이러한 기능을 사용하는 경우 시작하기 대시보드와 API를 계획하고 운영하기 위해 Using @capgo/capacitor-nfc Using @capgo/capacitor-nfc API 개요 API 개요에 대한 구현 세부 정보를 위해 소개 __CAPGO_KEEP_0__ 키에 대한 구현 세부 정보를 위해 API 키 API 키 및 장치에 대한 구현 세부 정보를 위해 장치 __CAPGO_KEEP_0__에 대한 구현 세부 정보를 위해