react-native-nfc-manager icon indicating copy to clipboard operation
react-native-nfc-manager copied to clipboard

Error: java.io.IOException while writing NfcManager.ndefHandler.writeNdefMessage(bytes)

Open pruthvirajkarurcodewave opened this issue 2 years ago • 0 comments

Hi I am trying to read an NFC and Write it back in **android Samsung Galaxy M51 and multiple other devices also. Same happens in iOS devices aswell **

While it works for ideal case when the user taps first time for reading and takes the tag away. Then brings the tag near again to Write it back.

In other case when the user keeps the phone on top of the NFC tag and then tries to write it to the tag while the tag is still under the phone touching it, then sometimes the data in the tag is getting clear and we are getting "Error: java.io.IOException" , or "unsupported tag api" or "Tag is not ndef" errors.

When this "Error: java.io.IOException" comes, the data from the NFC tag get cleared out.

Please suggest on how to resolve this error.

Below is the code used:

  await NfcManager.requestTechnology(NfcTech.Ndef);
    const bytes = Ndef.encodeMessage([Ndef.textRecord('Hello NFC')]);
    if (bytes) {
      await NfcManager.ndefHandler // STEP 2
        .writeNdefMessage(bytes); // STEP 3
       }
Versions used:
    "react-native": "0.68.1",
    "react-native-nfc-manager": "^3.13.2",
NFC type:
NFC type4A - ISO/IEC 14443A
Tech List: 
android.nfc.tech.IsoDep
android.nfc.tech.NfcA
android.nfc.tech.Ndef

pruthvirajkarurcodewave avatar Sep 12 '22 08:09 pruthvirajkarurcodewave