revtel / react-native-nfc-manager

React Native NFC module for Android & iOS
MIT License
1.38k stars 317 forks source link

Data is clearing while trying to write to the NFC #604

Closed pruthvirajkarurcodewave closed 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 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: 0.68.1

react-native-nfc-manager: ^3.14.2, `

pruthvirajkarurcodewave commented 1 year ago

@whitedogg13 Any idea what could be happening here ? Could you please check how to resolve this.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.

thechosenweak commented 6 months ago

I encountered the same issue on iOS. How can I prevent it from being cleared?