Skip to content

fix(ios): deliver tag when NDEF probe fails instead of dropping discovery#273

Open
apartx wants to merge 1 commit into
okadan:mainfrom
apartx:fix/ios-deliver-tag-on-ndef-probe-error
Open

fix(ios): deliver tag when NDEF probe fails instead of dropping discovery#273
apartx wants to merge 1 commit into
okadan:mainfrom
apartx:fix/ios-deliver-tag-on-ndef-probe-error

Conversation

@apartx

@apartx apartx commented Jun 18, 2026

Copy link
Copy Markdown

Problem

On iOS, convert(_ value: NFCNDEFTag, ...) performs an NDEF probe (queryNDEFStatusreadNDEF) immediately after the tag connects. If either step fails, it calls completionHandler(nil, error), which propagates as a failed connect — so the Dart onDiscovered callback never fires and the discovery is silently lost.

This breaks tags that are perfectly usable over their type-specific interface but return a transient error from the NDEF probe. In particular, NTAG21x-compatible clone chips intermittently return CoreNFC Stack Error (code 104) or No response from tag (code 102) for queryNDEFStatus/readNDEF right after connecting, even though raw sendMiFareCommand reads/writes work fine. On those tags onDiscovered fires only occasionally (or never), making them effectively undetectable through this plugin — while other apps that use a plain NFCNDEFReaderSession / raw session read them instantly.

Fix

Make the NDEF probe best-effort. On a probe error, still deliver the TagPigeon instead of dropping it:

  • queryNDEFStatus error → deliver the tag without NDEF info.
  • readNDEF error → deliver the tag with the status/capacity already obtained, just without a cached message.

The app keeps the discovery and can communicate with the tag over its raw interface (sendMiFareCommand, etc.). Successful probes are completely unchanged, so NDEF reading behavior for well-behaved tags is identical.

Notes

  • Pure iOS-side change, single function (convert(NFCNDEFTag)), no public API change.
  • readNDEF already special-cased code 403 ("no NDEF message present") as non-fatal; this generalizes the same "never lose the discovery over a probe error" principle to all probe failures.

…very

On iOS, convert(NFCNDEFTag) runs queryNDEFStatus/readNDEF right after
connecting and, if either fails, calls completionHandler(nil, error).
That propagates as a failed connect and the Dart onDiscovered callback
never fires, so the discovery is silently lost.

Some tags — notably NTAG21x-compatible clone chips — intermittently
return a transient CoreNFC "Stack Error" / "No response from tag" for
the NDEF probe even though the tag is fully usable over the
type-specific interface (e.g. sendMiFareCommand). On those tags the app
can never reliably discover the tag.

Make the NDEF probe best-effort: on a probe error, still deliver the
TagPigeon (without NDEF info, or with status/capacity but no cached
message) so the app keeps the discovery and can talk to the tag over
its raw interface. Successful probes are unchanged.
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.

2 participants