Tag handed to you by a session is deliberately almost empty. It has an
identifier, a list of technologies, a platform, and two platform facets. It has no
technology methods at all until you narrow it.
What is on every tag
Uint8Array | null
The UID, or
null when the platform does not expose one.string | null
The same as lowercase hex. Convenience for logging and comparison — and on the web, where Chrome
reports the serial with colons, this is normalised so it reads the same everywhere.
TagTech[]
The technologies this tag actually supports, here, on this platform. Worth logging in a bug
report.
NfcPlatform
ios, android or web.boolean
Whether the tag is gone: released, lost, or its session closed.
(tech: TagTech) => boolean
The type guard. This is the only way to reach a technology’s methods.
(listener: () => void) => Subscription
Fires when the tag leaves the field. Android only —
capabilities.tagLost says whether the
platform delivers this directly or it is polled for, which is a difference of latency. CoreNFC has
no removal callback at all, so on iOS a tag that has gone surfaces as the next operation failing
with tagLost.The technologies, and what each unlocks
Typed helpers over
transceive — ISO 7816 with chaining, ISO 15693, FeliCa, NTAG
password auth — live in /protocols as plain TypeScript.
NDEF
readNdefBytes is the escape hatch for a tag this library’s decoder rejects: you still get the
bytes and can decide what to do with them.ISO-DEP, and the APDU shape
[...bytes, sw1, sw2] on iOS and the raw bytes on Android — with a
// TODO: make following data the same format as Android in its own source
admitting it. If you have platform branches around a transceive, delete them.
Raw exchange
maxTransceiveLength rejects with transceiveTooLong rather
than being truncated.
Platform facets
tag.android and tag.ios are undefined on the other platform, so a facet you
forgot to guard is a type error rather than a crash.
- Android
- iOS
How long a tag is valid
A tag is valid for exactly as long as the session that produced it, and using one afterwards rejects withsessionClosed.
Tags that go away mid-operation
capabilities.tagLost reports native when the platform delivers
removal directly and polled when it is checked for on an interval. On iOS it is
none: the departure surfaces as the next operation rejecting with tagLost,
which is recoverable, so a retry is worth offering.
Checking a device rather than a tag
/dev/bcm2079x-i2c and /dev/pn544, scanned /system/lib, and carried a hardcoded
special case for one Lenovo model — all of it guesswork about a question the
platform answers directly.
Next
The NDEF codec
Every record type, chunking, and tag-level framing.
Protocols
ISO 7816, ISO 15693, FeliCa and NTAG over one primitive.