feat: Report NFC antenna location and Secure NFC status - #2
Merged
Merged
Conversation
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>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
'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 theposition 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 resolvesnull— neverrejects — 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 NFCto 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;
falsewhere the setting does not exist. It is a call rather than a capabilitybecause the user can change it while the app is running.
Both are reflected in
nfc.capabilitiesasantennaInfoandsecureNfc, and thereis a new page in the docs covering the coordinate system, foldables, and why
nullis 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
contractMismatchuntilnpx expo run:android,npx expo run:iosor an EAS build has run again.