SkateSpots/packages/skatespots-nfc/README.md
SkateSpots 7d51fc60a5 feat(nfc): native Android tag-writer plugin (APK) + Web NFC on web
Web NFC isn't exposed in Capacitor's WebView, so the APK needs a native writer.
Adds packages/skatespots-nfc — a local Capacitor Android plugin (Kotlin,
enableReaderMode + NDEF URL record), registered BY NAME (not bundled). lib/nfc.ts
now uses the plugin on native and Web NFC on the web. iOS can't write tags.
⚠️ UNVERIFIED (needs cap sync + a device). README documents it.
2026-10-02 14:14:31 +07:00

26 lines
1.2 KiB
Markdown

# skatespots-nfc (local Capacitor Android plugin)
Writes the card/pass **verify URL** to an NFC tag from inside the SkateSpots APK.
**Why a plugin?** Web NFC (`NDEFReader`) is not exposed inside Capacitor's
WebView, so the browser path in `src/lib/nfc.ts` can't run in the APK. On the web
(Chrome/Android) the app uses Web NFC; in the APK it uses this plugin.
**What it writes:** only a single NDEF **URL record** — the same pointer the QR
carries. A tag is passive and can be cloned like a QR; trust comes from the relay
signature, verified at `/#/verify/<naddr>`.
## Wiring
- `package.json` has `"skatespots-nfc": "file:packages/skatespots-nfc"` so
`npx cap sync android` adds the module.
- The app registers the plugin **by name** (`registerPlugin('SkateSpotsNfc')`); it
does not import this package into the web bundle.
- Permissions (`NFC`, optional `uses-feature`) merge from the plugin manifest.
## API
`isSupported(): { supported }` · `writeUrl({ url })` · `cancel()`
## ⚠️ Unverified
Needs `npm run android:sync` + a real device. Android-only (iOS sandboxes NFC
writing). The Kotlin uses `NfcAdapter.enableReaderMode`; tune per the app's
Capacitor version if Gradle complains.