Skip to content

Verify local NFC writes before reporting success #183

Description

@wizzomafizzo

Problem

Local NFC writes can appear successful in the app, but Core subsequently reads the tag as a valid NTAG213 containing a non-nil NDEF message with zero records. Affected users report that fresh tags written by the app fail until rewritten once by Core/MiSTer.

Related reports:

One report also notes intermittent tag-connection errors whose failure toast is obscured behind the active scan interface.

Evidence

From the latest affected-device log: https://logs.zaparoo.org/zFGqNLnh.log

  • Tag 0498f466bc2a81 was scanned six times. Every scan identified a genuine NXP NTAG213 but returned zero NDEF records.
  • Tag 049df466bc2a81 initially returned zero records. Core rewrote it at 08:53:30; every logged scan afterward returned one text record and launched successfully.
  • At 22:18, the reader alternated between the failing and working tags: 0498... failed, 049d... succeeded twice, then 0498... failed again. This points to persistent tag contents/write outcome rather than intermittent Core reading.

Current writeTag behavior in src/lib/nfc.ts treats a resolved Nfc.write() call as success. It does not read back and compare the stored NDEF message before useNfcWriter displays the success toast.

Desired behavior

  • Verify local NFC writes by reading back the tag and comparing the stored NDEF record with the requested text.
  • Do not report success until verification passes.
  • Treat empty, mismatched, or unreadable post-write data as a write failure with a clear retry message.
  • Keep failure feedback visible above or after the scan interface rather than obscured behind it.
  • Cover successful verification, mismatch, empty NDEF, connection loss, and cancellation with tests.

If the current Capacitor NFC API cannot read the connected tag immediately after writing, use either a deliberate second-tap verification flow or extend the native plugin to expose post-write NDEF read-back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions