SkateSpots/packages/skatespots-nfc/src/index.ts
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

22 lines
897 B
TypeScript

/**
* SkateSpots NFC writer — TS↔Kotlin bridge.
*
* Web NFC isn't exposed inside Capacitor's WebView, so the APK writes tags via
* this local plugin. It writes ONLY the verify URL (the same pointer the QR
* carries). On the web, `src/lib/nfc.ts` falls back to Web NFC.
*
* The app registers this plugin BY NAME via `@capacitor/core`; it does not
* import this package into the web bundle.
*/
import { registerPlugin } from '@capacitor/core';
export interface SkateSpotsNfcPlugin {
/** Whether the device has an NFC adapter. */
isSupported(): Promise<{ supported: boolean }>;
/** Enable reader mode and write the URL to the first NDEF tag tapped. */
writeUrl(options: { url: string }): Promise<void>;
/** Stop waiting for a tag and reject the pending write. */
cancel(): Promise<void>;
}
export const SkateSpotsNfc = registerPlugin<SkateSpotsNfcPlugin>('SkateSpotsNfc');