revtel / react-native-nfc-manager

React Native NFC module for Android & iOS
MIT License
1.4k stars 318 forks source link

Inconsistent Length Byte in NDEF Text Messages on iOS #755

Closed zataara closed 3 weeks ago

zataara commented 1 month ago

When writing a text NDEF message to an NFC tag using the react-native-nfc-manager package, there is an issue where the length byte of the NDEF message is sometimes set to 0, causing the message to be unreadable. This issue only occurs on iOS and behaves inconsistently.

Steps to Reproduce:

  1. Write a text NDEF message to an NFC tag, using a string passed as a parameter to the writeNdef function.
  2. Read the tag to verify the message.
  3. Observe that the length byte is sometimes set to 0.

Notes:

Expected Behavior:

The length byte should be set correctly regardless of whether the string is hardcoded or passed as a parameter.

Actual Behavior:

In some cases, when passing a string as a parameter, the length byte is set to 0, causing the NDEF message to be unreadable.

Environment:

Screenshots

The second byte in Block 0002 is the length byte. Left image was written using this library. Right image was written using NFC Tools application (Native iOS) with same message.

LengthByteMissing