메뉴로 바로가기

Getting Started

GitHub

설치

설치

AI-Assisted 설치를 사용하여 플러그인을 설치할 수 있습니다. 다음 명령어를 사용하여 AI 도구에 Capgo 기능을 추가하세요:

터미널 창
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

다음과 같은 프롬프트를 사용하세요:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-nfc` plugin in my project.

만약 Manual Setup을 선호한다면, 플러그인을 설치하기 위해 다음 명령어를 실행하고 아래의 플랫폼별 지침을 따르세요:

터미널 창
bun add @capgo/capacitor-nfc
bunx cap sync
import { CapacitorNfc } from '@capgo/capacitor-nfc';

API 개요

API 개요

NFC 태그를 감지하기 시작합니다.

import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.startScanning();

현재 진행 중인 NFC 스캔 세션을 중지합니다.

import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.stopScanning();

제공된 NDEF 레코드를 마지막으로 발견한 태그에 쓰기합니다.

import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.write({} as WriteTagOptions);

마지막으로 발견한 태그를 비어있는 NDEF 메시지를 쓰기하여 삭제하려고 시도합니다.

import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.erase();

최근 발견된 태그를 읽기 전용으로 만듭니다.

import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.makeReadOnly();

share

공유

Android에서만 다른 장치와 NFC 메시지를 공유합니다.

import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.share({} as ShareTagOptions);

이전으로 제공된 NFC 메시지를 중지합니다. (Android에서만)

import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.unshare();

현재 NFC 어댑터 상태를 반환합니다.

import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.getStatus();

showSettings

설정 보기

NFC를 사용할 수 있도록 하기 위해 시스템 설정 페이지를 엽니다.

import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.showSettings();

장치가 NFC 하드웨어 지원을 가지고 있는지 확인합니다.

반환 true 장치에 NFC 하드웨어가 있으면, NFC가 현재 활성화되거나 비활성화되어도 항상 true를 반환합니다. 장치에 NFC 하드웨어가 없으면 항상 false를 반환합니다. false 이 메서드를 사용하여 NFC 기능이 표시되어야 하는지 여부를 결정하세요. NFC가 현재 활성화되어 있는지 여부를 확인하려면

타입 참조 getStatus().

import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.isSupported();

NFC 기능을 앱의 UI에 표시할지 여부를 결정하기 위해 NFC 하드웨어가 장치에 있는지 여부를 확인하세요.

타입 참조

StartScanningOptions

스캔 시작 옵션

__CAPGO_KEEP_0__

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__

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_0__

export interface ShareTagOptions {
records: NdefRecord[];
}

NfcStatus

NFC 상태

__CAPGO_KEEP_0__

export type NfcStatus = 'NFC_OK' | 'NO_NFC' | 'NFC_DISABLED' | 'NDEF_PUSH_DISABLED';

NfcEvent

NfcEvent

플러그인이 NFC 장치 발견을 위해 내보내는 일반적인 NFC 발견 이벤트입니다.

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';

원본 네이티브 레이어에서 반환된 전체 태그 정보의 표현

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 개요 Capacitor API Overview 소개 소개 API 키 Capacitor API Keys 장치 Capacitor Devices