NFC __CAPGO_KEEP_0__ リポジトリ
このプラグインのセットアッププロンプトをコピーします。インストール手順とフルマークダウンガイドが含まれます。
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.
インストール
「インストール」のセクションAI-Assisted Setupを使用してプラグインをインストールできます。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-nfcbunx cap syncImport
__CAPGO_KEEP_0__の概要import { CapacitorNfc } from '@capgo/capacitor-nfc';APIの概要
APIガイドstartScanning
NFCタグの検出を開始します。ターミナル画面
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.startScanning();stopScanning
セクション「スキャンを停止」進行中のNFCスキャンセッションを停止します。
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.stopScanning();write
セクション「書き込み」最後に発見したタグに提供されたNDEFレコードを書き込みます。
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.write({ records: [ { tnf: 1, type: [1], id: [1], payload: [1], }, ],});erase
セクション「消去」最後に発見したタグを空のNDEFメッセージで書き込むことで消去を試みます。
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.erase();makeReadOnly
セクション「読み取り専用化」最後に発見したタグを読み取り専用にします。
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.makeReadOnly();share
「共有」セクションAndroid専用。別のデバイスにNDEFメッセージを共有します。
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.share({ records: [ { tnf: 1, type: [1], id: [1], payload: [1], }, ],});unshare
「共有を停止」セクションAndroid専用。以前提供したNDEFメッセージの共有を停止します。
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.unshare();getStatus
「getStatus」セクション現在のNFCアダプタの状態を取得します。
import { CapacitorNfc } from '@capgo/capacitor-nfc';
const result = await CapacitorNfc.getStatus();console.log(result);showSettings
「設定を表示」セクションシステム設定画面を開き、ユーザーがNFCを有効にすることができます。
import { CapacitorNfc } from '@capgo/capacitor-nfc';
await CapacitorNfc.showSettings();isSupported
「isSupported」セクションデバイスがNFCハードウェアのサポートを確認します。
戻り値 true デバイスにNFCハードウェアが存在する場合、NFCが有効または無効にかかわらず、trueを返します。 false デバイスにNFCハードウェアが存在しない場合、falseを返します。
このメソッドを使用して、NFC機能を表示するかどうかを決定するアプリのUIを設定します。NFCが現在有効かどうかを確認するには、 getStatus().
import { CapacitorNfc } from '@capgo/capacitor-nfc';
const result = await CapacitorNfc.isSupported();console.log(result);StartScanningOptions
「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
「WriteTagOptions」のセクション現在のタグにNDEFメッセージを書き込む際に使用されるオプション。
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
「ShareTagOptions」のセクションAndroid Beam / P2Pモードを使用して他のデバイスにNDEFメッセージを共有する際に使用されるオプション。
export interface ShareTagOptions { records: NdefRecord[];}NfcStatus
「NfcStatus」のセクションNFCアダプターの状態を返す。
export type NfcStatus = 'NFC_OK' | 'NO_NFC' | 'NFC_DISABLED' | 'NDEF_PUSH_DISABLED';NfcEvent
「NfcEvent」のセクションプラグインによって発行される一般的なNFC発見イベント。
export interface NfcEvent { type: NfcEventType; tag: NfcTag;}NfcStateChangeEvent
セクション「NfcStateChangeEvent」NFCアダプタの可用性が変更されたときに発行されるイベント。
export interface NfcStateChangeEvent { status: NfcStatus; enabled: boolean;}NdefRecord
セクション「NdefRecord」1つの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.tsAPIがアップストリームで変更された場合に、パブリック APIを再度同期してください。
続けて「Getting Started」
「続けて「Getting Started」」あなたが 「Getting Started」 ダッシュボードとAPIの計画と実行を管理する場合、 「@capgo/capacitor-nfc」を使用 「@capgo/capacitor-nfc」を使用して、 API まとめ API の概要 Introduction 導入 API キー API キー Devices デバイス