fix(ios): deliver tag when NDEF probe fails instead of dropping discovery#273
Open
apartx wants to merge 1 commit into
Open
fix(ios): deliver tag when NDEF probe fails instead of dropping discovery#273apartx wants to merge 1 commit into
apartx wants to merge 1 commit into
Conversation
…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.
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
On iOS,
convert(_ value: NFCNDEFTag, ...)performs an NDEF probe (queryNDEFStatus→readNDEF) immediately after the tag connects. If either step fails, it callscompletionHandler(nil, error), which propagates as a failed connect — so the DartonDiscoveredcallback 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) orNo response from tag(code 102) forqueryNDEFStatus/readNDEFright after connecting, even though rawsendMiFareCommandreads/writes work fine. On those tagsonDiscoveredfires only occasionally (or never), making them effectively undetectable through this plugin — while other apps that use a plainNFCNDEFReaderSession/ raw session read them instantly.Fix
Make the NDEF probe best-effort. On a probe error, still deliver the
TagPigeoninstead of dropping it:queryNDEFStatuserror → deliver the tag without NDEF info.readNDEFerror → deliver the tag with thestatus/capacityalready 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
convert(NFCNDEFTag)), no public API change.readNDEFalready special-cased code403("no NDEF message present") as non-fatal; this generalizes the same "never lose the discovery over a probe error" principle to all probe failures.