flutter-nfc-manager icon indicating copy to clipboard operation
flutter-nfc-manager copied to clipboard

NDEF tag does not contain any NDEF message

Open channdara opened this issue 1 year ago • 8 comments

Hi. I'm running into an issue with iOS cannot detect tag. I'm working with Mifare NTAG (ISO 14443) which can detect fine in Android platform but not iOS. There are no error in Flutter log at all but when I open Xcode, I received this error below:

Error Domain=NFCError Code=403 "NDEF tag does not contain any NDEF message" UserInfo={NSLocalizedDescription=NDEF tag does not contain any NDEF message}

I did some research and found a fix that required me to write a record to the TAG, whatever TEXT or URL or somethings. And yes, the issue gone and iOS platform can detect TAG normally. But the problem is, I cannot manually add record or tell user to add a record to all the TAGs. Is there any way to solve this issue? Am I doing something wrong or missing any iOS configuration? Please let me know, thank you so much.

My configuration on iOS side

  • I have added NFCReaderUsageDescription to info.plist
<key>NFCReaderUsageDescription</key>
    <string>This app uses NFC to scan and interact with compatible tags for enhanced functionality and a seamless user experience.</string>
  • I have added Near Field Communication Tag Reader Session Formats Entitlement
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
    <string>TAG</string>
</array>
  • I have added these to info.plist too
<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>
<array>
    <string>12FC</string>
    <string>0000</string>
</array>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
    <string>D2760000850100</string>
    <string>D2760000850101</string>
    <string>D2760001180101</string>
    <string>00000000000000</string>
</array>
  • I have added Near Field Communication Tag Reading under Signing & Compatibilities in Xcode

channdara avatar May 19 '25 07:05 channdara

I have fork the repo and make a small change on error condition in NfcManagerPlugin at line 507

if let error = error as? NSError, error.code != 403 {

I'm not a Swift guy and I know checking like this is not the correct way. Just want to point out there. If you have better solution please do so. Thank you.

channdara avatar May 19 '25 08:05 channdara

Hello, I’m facing the same issue. I have an NFC tag without NDEF data. It scans fine on Android, but it's not working on iOS and throws same error. I’ve searched everywhere but couldn’t find a solution. If you’ve found any fix, please let me know. @channdara @okadan

Priyanshu-Bej avatar Jun 17 '25 20:06 Priyanshu-Bej

@Priyanshu-Bej

I have a temporary fix in the forked repo here: https://github.com/channdara/flutter-nfc-manager Can be use for workaround for now, still waiting for the main repo to update this.

channdara avatar Jun 18 '25 03:06 channdara

Thanks man @channdara , this works for now — but it should be fixed in the official package as soon as possible. @okadan

Priyanshu-Bej avatar Jun 18 '25 12:06 Priyanshu-Bej

For everyone wondering how you can use @channdara's excellent fix (thank you!), add this to your pubsec.yaml:

dependency_overrides:
  # Override as `nfc_manager` currently does not scan tags with empty NDEF blocks on iOS
  # TODO: Check if still required for nfc_manager versions > 4.0.2
  nfc_manager:
    git:
      url: https://github.com/channdara/flutter-nfc-manager.git
      path: packages/nfc_manager
      commit: d5480bc

With that, you can keep your original nfc_manager import in the dependencies block, but when building, the commit with the fix will be used instead.

komaxx avatar Jul 03 '25 09:07 komaxx

Any word on official fix being released? As appreciated as it is to have an option, I hesitate to use @channdara's fix in my production app. Thanks @okadan

smplfy avatar Jul 22 '25 14:07 smplfy

For everyone wondering how you can use @channdara's excellent fix (thank you!), add this to your pubsec.yaml:

dependency_overrides:

Override as nfc_manager currently does not scan tags with empty NDEF blocks on iOS

TODO: Check if still required for nfc_manager versions > 4.0.2

nfc_manager: git: url: https://github.com/channdara/flutter-nfc-manager.git path: packages/nfc_manager commit: d5480bc With that, you can keep your original nfc_manager import in the dependencies block, but when building, the commit with the fix will be used instead.

This fixes the iOS scanning bug (so, thanks a lot) but a worrying error message still appears :

[ERROR:flutter/shell/common/shell.cc(1064)] The 'dev.flutter.pigeon.nfc_manager.FlutterApiPigeon.tagSessionDidBecomeActive' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.

Also there is still an error of still existant instance when we cancel the iphone nfc scanning modal and try to ask for another scan.

Is there any update of the package planned ?

HeropolisDa2ny avatar Aug 25 '25 09:08 HeropolisDa2ny

Hello @okadan , I would like to know if you were planning on continuing updating the package or should we switch to another one ?

HeropolisDa2ny avatar Mar 20 '26 15:03 HeropolisDa2ny