nfc

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emit

func Emit(event string, data any)

Emit delivers an NFC event (e.g. a scanned tag) to the frontend via whatever sink RegisterNFC installed. Exported so native providers bound through gomobile — which can't reach this package's unexported state — can push events without going through the Provider interface itself.

func SetEventSink

func SetEventSink(fn func(event string, data any))

SetEventSink registers the function used to deliver NFC events to the frontend. Safe to call with nil to clear it.

func SetProvider

func SetProvider(p Provider)

func StartScan

func StartScan() error

func StopScan

func StopScan() error

func Write

func Write(message NFCMessage) error

Types

type NFCMessage

type NFCMessage struct {
	Records []NFCRecord `json:"records"`
}

type NFCRecord

type NFCRecord struct {
	Type      string `json:"type"`
	MediaType string `json:"mediaType"`
	Data      []byte `json:"data"`
}

type Provider

type Provider interface {
	StartScan() error
	StopScan() error
	Write(message NFCMessage) error
}

Provider is a native NFC backend. On mobile the shell registers one via SetProvider (android.nfc / CoreNFC) and delivers scanned tags through the bridge event channel. Desktop machines have no NFC reader API; Chrome on Android exposes Web NFC as a fallback.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL