Skip to content

feat: Report NFC antenna location and Secure NFC status - #2

Merged
visibait merged 2 commits into
mainfrom
feat/antenna-location
Sep 10, 2026
Merged

visibait merged 2 commits into
mainfrom
feat/antenna-location

Conversation

@visibait

Copy link
Copy Markdown
Owner

'react-native-nfc-kit': minor

Report where the device's NFC antenna is, and whether Secure NFC is on.

nfc.getAntennaInfo() answers with the device's dimensions in millimetres and the
position of each NFC antenna within them, which is what turns "hold the card here"
into a hint drawn in the right place instead of in the middle of the screen. Android
14 and later, through NfcAdapter.getNfcAntennaInfo. It resolves null — never
rejects — on iOS, on the web, below Android 14, and on the many Android 14 devices
whose manufacturer left the numbers empty, so a screen laying out a hint needs no
try/catch and still has to keep its generic fallback.

nfc.isSecureNfcEnabled() reports Android's Secure NFC setting, which restricts NFC
to an unlocked screen and is the usual explanation for a background or launch tag
that silently does nothing on one device and works on another. Android 10 and later;
false where the setting does not exist. It is a call rather than a capability
because the user can change it while the app is running.

Both are reflected in nfc.capabilities as antennaInfo and secureNfc, and there
is a new page in the docs covering the coordinate system, foldables, and why null
is a normal answer.

This bumps the native contract to version 6, so a development build has to be
rebuilt.
Updating the JavaScript alone leaves the installed binary reporting
version 5, and every call will fail with contractMismatch until
npx expo run:android, npx expo run:ios or an EAS build has run again.

visibait and others added 2 commits September 10, 2026 20:26
Android 14 added NfcAdapter.getNfcAntennaInfo, which says where the NFC
antenna physically sits on the device. Exposed as nfc.getAntennaInfo():
the device's dimensions in millimetres and each antenna's position within
them, so an app can draw "hold the card here" over the antenna instead of
in the middle of the screen.

It resolves null rather than rejecting on iOS, on the web, below API 34,
and on the many API 34 devices whose manufacturer left the numbers empty.
That last case is the reason: a caller already has to handle "this device
does not say" on Android 14, so a second, platform-shaped error path would
be one branch too many for a hint that is progressive enhancement anyway.

Alongside it, nfc.isSecureNfcEnabled() reports Android's Secure NFC
setting, which restricts NFC to an unlocked screen and is the usual
explanation for a launch tag that silently does nothing on one device and
works on another. A call rather than a capability, because the user can
change it while the app is running.

Both are reflected in nfc.capabilities as antennaInfo and secureNfc, both
asked of the adapter rather than inferred from the API level.

Bumps the native contract to 6, so a development build has to be rebuilt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Applies the antenna-location changeset: minor, because the native contract
moved to 6 and consumers have to rebuild their development build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@visibait
visibait merged commit b201cca into main Sep 10, 2026
9 checks passed
@mintlify

mintlify Bot commented Sep 10, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
react-native-nfc-kit 🟢 Ready View Preview Sep 10, 2026, 6:30 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant