revtel / react-native-nfc-rewriter

NFC open reader app in React Native
MIT License
193 stars 85 forks source link

DATA gets cleared while doing write operation on NFC TAG #50

Open pruthvirajkarurcodewave opened 1 year ago

pruthvirajkarurcodewave commented 1 year ago

Hi Team,

Data in the NFC is getting erased. Our product is already live and erase issues are coming which is very alarming for the business. Please help us out in resolving in this issue.

I am using the following code for writing please suggest.

` const writeTestFinal = async text => {

var result = false;

let type = 'TEXT';

try {

  var value = 'test data to write';

  await NfcManager.requestTechnology(NfcTech.Ndef, {
    alertMessage: 'Ready to write some NDEF',
  });

  let bytes = null;
  if (type === 'TEXT') {
    bytes = Ndef.encodeMessage([Ndef.textRecord(value)]);
  } else if (type === 'URI') {
    bytes = Ndef.encodeMessage([Ndef.uriRecord(value)]);
  }

  if (bytes) {
    await NfcManager.ndefHandler.writeNdefMessage(bytes);

    result = true;
  }
} catch (ex) {
  console.warn('ERROR IN WRITETESTFINAL : ', ex);
} finally {
  NfcManager.cancelTechnologyRequest();
}

return result;

};` Happy flow works: If the users just taps just once then the data write successfully.

Real world scenario: If the user tries to move the nfc fast to make the transfer fast and moves the nfc in a circular format attached to the device then the NFC tag is getting cleared after this line await NfcManager.ndefHandler.writeNdefMessage(bytes); I tried with the existing application from the playstore /appstore NFC Rewriter in that app also i am getting this issue of data clearance . Please suggest how to resolve this.

Debug info:

"react-native-nfc-manager": "^3.14.2", "react-native": "0.68.1",