Skip to content

Getting Started

설치

설치
터미널 창
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();

stopScanning

__CAPGO_KEEP_0__

__CAPGO_KEEP_1__

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

__CAPGO_KEEP_4__

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

__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);

이전으로 제공된 NDEF 메시지를 중지합니다 (안드로이드만).

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

클립보드에 복사

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

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[];
}

__CAPGO_KEEP_7__

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

__CAPGO_KEEP_10__

export interface NfcEvent {
type: NfcEventType;
tag: NfcTag;
}

NfcStateChangeEvent

NfcStateChangeEvent 섹션

NFC 어댑터 가용성 변경 시 발생하는 이벤트.

export interface NfcStateChangeEvent {
status: NfcStatus;
enabled: boolean;
}

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[];
}

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 개요 API 개요에 대한 구현 세부 정보를 위해 소개 __CAPGO_KEEP_0__ 키에 대한 구현 세부 정보를 위해 API 키 API 키 및 장치에 대한 구현 세부 정보를 위해 장치 __CAPGO_KEEP_0__에 대한 구현 세부 정보를 위해