Where to tell the user to tap
Android 14 added an API that reports where the NFC antenna physically sits on the device. It is the difference between a card illustration in the middle of the screen and one over the antenna.The coordinates are millimetres from the bottom-left corner of the device — the corner of the
hardware, bezels included. They are not screen coordinates and not pixels, so they mean nothing on
their own. That is why
deviceWidth and deviceHeight come back in the same object: it is the
ratio of the two that becomes a position you can lay out against.antennas is ordered as the platform
gives it, with no promise about which is the “main” one. Most devices report exactly
one.
When it is null
null is a normal answer, not a failure, and it covers four different situations on
purpose:
The last row is the one worth designing around: it means the
null branch is not “the
iOS branch” by another name, and a device on the right Android version can still
decline to answer. Keep the generic illustration as the fallback.
Because of that, getAntennaInfo() resolves null rather than rejecting — a screen
laying out a hint needs no try/catch. If you want the answer without the round
trip, nfc.capabilities?.antennaInfo is the same fact as a boolean.
On a foldable,
deviceFoldable is true and every number describes the device unfolded. A
folded phone needs its own arithmetic before any of this reaches a layout, and the platform gives
you nothing to do it with — so on a foldable, showing the generic hint is usually the better
answer.Secure NFC
Android 10 added a setting called Secure NFC: when it is on, the device reads tags only while the screen is unlocked. It is off by default on most devices and on by default on a few, and a user can turn it on without connecting it to anything.nfc.capabilities?.secureNfc, which is false below Android 10, on iOS and on the
web — and isSecureNfcEnabled() is false there too.
It matters most for background and launch tags: a tap
against a locked phone is exactly what that feature is for, and Secure NFC is the
reason it silently does nothing on some devices. A reading session started from a
screen the user is looking at is unaffected, because the screen is unlocked by
definition.
What each platform reports
Neither call needs a permission, an entitlement, or anything in the manifest. Both are
safe to call on every platform on startup.