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.
22 lines
897 B
TypeScript
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');
|