Notable to get NFC tag information only get ID and Tech Type in react native nfc manager

822 Views Asked by At

I am trying to read information form Nfc tag that is written here is my code. NFC reads tag id and its type not able to read other information that we write I am using react native nfc manager

try {
      await NfcManager.requestTechnology(NfcTech.Ndef);
      const tag = await nfcManager.getTag();
      if(tag){
       const message= await nfcManager.ndefHandler.getNdefMessage();
        const status = await nfcManager.ndefHandler.getNdefStatus();
        await  db.collection('Tags').add({
          tag:tag,
          Data:message,
          status:status,
        })
      }
    }

enter image description here

only ID and Techtype it showns not able to show idr information

I am epecting to someone guide me issue that I faced in my code and Want able to run NFC manager

1

There are 1 best solutions below

0
david maene On

the content of the message you wrote is in payload for that just call the method getNdefMessage() like this

NfcManager.ndefHandler.getNdefMessage()
        .then(message => {
          // NfcTech.Ndef.uri.decodePayload(message['ndefMessage'][0]['payload']);
          settag((Ndef.uri.decodePayload(message['ndefMessage'][0]['payload'])).toString())
        })
        .catch(err => {
    // catch error here
})