Aller directement au contenu principal
Retour aux plugins
@capgo/capacitor-nfc
Tutoriel
par github.com/Cap-go

NFC

Découverte, lecture et écriture de tags NFC natifs pour les applications Capacitor sur iOS et Android

Guide

Tutoriel sur NFC

Utilisation de @capgo/capacitor-nfc

Surface publique API pour le plugin NFC Capacitor.

Installer

bun add @capgo/capacitor-nfc
bunx cap sync

Ce que ce plugin expose

  • startScanning - Démarre la recherche de balises NFC.
  • stopScanning - Arrête la session de balise NFC en cours.
  • write - Écrit les enregistrements NDEF fournis sur la dernière balise découverte.
  • erase - Tente d'effacer le dernier tag découvert en écrivant un message NDEF vide.

Exemple d'utilisation

startScanning

Démarrer l'écoute des balises NFC.

import { CapacitorNfc } from '@capgo/capacitor-nfc';

await CapacitorNfc.startScanning();

stopScanning

Arrêtez la session de balise NFC en cours.

import { CapacitorNfc } from '@capgo/capacitor-nfc';

await CapacitorNfc.stopScanning();

write

Écrit les enregistrements NDEF fournis sur le dernier tag découvert.

import { CapacitorNfc } from '@capgo/capacitor-nfc';

await CapacitorNfc.write({} as WriteTagOptions);

erase

Tente d'effacer le dernier tag découvert en écrivant un message NDEF vide.

import { CapacitorNfc } from '@capgo/capacitor-nfc';

await CapacitorNfc.erase();

Référence complète