Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pruthvirajkarurcodewave opened this issue Sep 12, 2022 · 0 comments

Comments

@pruthvirajkarurcodewave
Copy link

pruthvirajkarurcodewave commented Sep 12, 2022

Hi I am trying to read an NFC and Write it back in android Samsung Galaxy M51. and tried in multiple other android phones as well. Same happens even in iOS devices.

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.

### The issue is in NfcProxy.js in writeNdef method.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant