2

Form the last 3 days I trying to get the string values from my NFC card but I can't. when I scan the card then the "getTag()" function get shows some values in the log but in that value, I can't find the string which is stored in the tag.

Here is my Code which I tried first:-

    try {
        NfcManager.start();
        await NfcManager.requestTechnology(NfcTech.NfcA);
        const tag1 = await NfcManager.getTag();

        console.log(" ~ file: NFC.js ~ line 41 ~ readTags ~ tag", JSON.stringify(tag1))
    } catch (ex) {
        console.warn('Oops!', ex);
    }

Code I tried a second time: -

   try {
        let tech = Platform.OS === ' ios ' ? NfcTech.MifareIOS : NfcTech.NfcA;
        let resp = await NfcManager.requestTechnology(tech, {
            alertMessage: " Ready for magic "
        });
        let i;
        NfcManager.start();
        let cmd = Platform.OS === 'ios' ? NfcManager.sendMifareCommandIOS : NfcManager.transceive;
        resp = await cmd([0x3A, 4, 4])
        let payloadLength = parseInt(resp.toString().split(",")[1]);
        let payloadPages = Math.ceil(payloadLength / 4);
        let startPage = 5;
        let endPage = startPage + payloadPages - 1;

        resp = await cmd([0x3A, startPage, endPage]);
        let bytes = resp.toString().split(",");
        console.log(" ~ file: NFC.js ~ line 51 ~ readTags ~ bytes", bytes)
        let text = "";

        for (let i = 0; i < bytes.length; i++) {
            if (i < 5) {
                continue;
            }
        }
        if (parseInt(bytes[i]) === 254) {
            return;
        }

        text = text + String.fromCharCode(parseInt(bytes[i]));
        console.log(" ~ file: NFC.js ~ line 61 ~ readTags ~ text", JSON.stringify(text))


    } catch (ex) {
        console.warn('Oops!', ex);
    }

Card Info: This is the card information which I am using.

enter image description here

Can anyone help me to get rid of this problem?

varun
  • 57
  • 3
  • It would help if you specified the exact make and model of the Tag you are trying to read and details of how you stored the "String" on the Tag (as usually a NFC Tag just stores a byte array). So the "String" will be encode in some format (usually Ndef). It would be worth using the NXP "Taginfo" App to do a full scan of the Tag and then use the save functionality to save it to a xml file and then post the xml file in your question (Don't post pictures of the App screen), so we can understand actually what data you have. – Andrew Oct 04 '22 at 17:01
  • I tried Two times types of code to get the card string value in my first code I get the card information but in that information string doesn't available, did u check my first code? @Andrew – varun Oct 05 '22 at 04:36
  • I did check the code, but cannot say how to do it right without more info about the Tag – Andrew Oct 05 '22 at 08:08
  • it's a normal tag which I got from my seniors, so I don't know more information about this tag. @Andrew – varun Oct 05 '22 at 10:38
  • If you read my comment I tell you how to get more info on the Tag – Andrew Oct 05 '22 at 10:49
  • Information is added about my card. @Andrew – varun Oct 05 '22 at 11:14
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/248559/discussion-between-varun-and-andrew). – varun Oct 05 '22 at 11:16

0 Answers0