nfc: add support for NFC Forum Type 1/2 tags (NTAG213/215/216)#809
Open
AxelHamburch wants to merge 1 commit into
Open
nfc: add support for NFC Forum Type 1/2 tags (NTAG213/215/216)#809AxelHamburch wants to merge 1 commit into
AxelHamburch wants to merge 1 commit into
Conversation
The NFC reader previously only accepted ISO-DEP (NFC Forum Type 4) tags such as NTAG424-DNA and Bolt Cards. Tags based on the NFC Forum Type 2 spec, like the widely-used NTAG213, NTAG215 and NTAG216 family, were silently dropped because IsoDep.get(tag) returns null for them. Add a fallback path in NfcReaderCallback that uses the Android Ndef API to read NDEF messages directly from Type 1/2 tags whenever a tag is not ISO-DEP capable. The existing APDU-based ISO-DEP flow is unchanged. The two paths were also refactored into separate private methods (readIsoDepTag / readNdefTag) to improve readability.
dpad85
approved these changes
May 13, 2026
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.
Problem
The NFC reader in Phoenix only works with ISO-DEP (NFC Forum Type 4) tags such as NTAG424-DNA and Bolt Cards. Tags from the widely-used NTAG21x family (NTAG213, NTAG215, NTAG216) are silently dropped without any payment being initiated.
What happens today
NfcReaderCallback.onTagDiscovered()is calledIsoDep.get(tag)returnsnullbecause NTAG21x tags implement NFC Forum Type 2 (ISO 14443-3A), not ISO-DEP (ISO 14443-4)NTAG21x tags are extremely common — they are used by many Lightning payment terminals, NFC stickers, and payment devices to encode LNURL-pay / Lightning invoice URIs as plain NDEF records.
Other Lightning wallets already handle this
The following Lightning wallets read NTAG21x tags without issues:
Phoenix is currently the only major Android Lightning wallet where NTAG21x tags do not trigger a payment.
Root cause
NfcReaderCallbackexclusively callsIsoDep.get(tag). If that returnsnullthe entire tag is rejected. There is no fallback for the AndroidNdeftechnology class, which is the correct API for NFC Forum Type 1/2 tags.Fix
Add a fallback path in
NfcReaderCallbackthat usesNdef.get(tag)when a tag is not ISO-DEP capable:The
readNdefTag()method callsndef.ndefMessagedirectly — no APDU commands needed. The NDEF record is then parsed by the existingNdefParser, so all supported URI/text schemes (LNURL, Lightning, Bitcoin, …) work out of the box.The existing ISO-DEP path is completely unchanged. Only one file is modified.
Changed file
phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/utils/nfc/NfcReaderCallback.ktimport android.nfc.tech.NdefaddedonTagDiscoveredrefactored:isReading()guard moved to top, two tech branches addedreadIsoDepTag(isoDep: IsoDep)readNdefTag(ndef: Ndef)addedTesting
Tested with:
lnurlp://...— payment screen opens correctlyNo changes to
AndroidManifest.xmlare required:FLAG_READER_NFC_Ais already set instartNfcReader(), which covers both Type 2 and Type 4 NFC-A tags.