skip to Main Content

I use C#.Net to create web app on an Android device. Is it possible to read a Mifare card through NFC on an Android device with Javascript like this and handling NFC Events?
I want to read block 1 of Mifare and using factory default keys 0x FF FF FF FF FF FF

in aspx file:

        </td>
        <td class="auto-style59">&nbsp;</td>
    </tr>
</table>
  ...

<script src="jquery.js"></script> 

<script type="text/javascript">
    function NFCRead() {
        ...
    }
</script>

</asp:Content> 

I have tried other ways and still no success

2

Answers


  1. As you added detail that suggests that the Tag is a Mifare Classic Tag and you are wanting to read Block 1, then this is not using the Ndef Data format so the answer is No this is not possible with just Javascript.

    Only possible with a Native App.

    Login or Signup to reply.
  2. You have to call this function when you scan card.

    function NFCRead() {
       try {
                const ndef = new NDEFReader();
                await ndef.scan();
                ndef.addEventListener("readingerror", () => {
                    console.log("Argh! Cannot read data from the NFC tag. Try another one?");
                });
                ndef.addEventListener("reading", ({ message, serialNumber }) => {
                    // convert Serial Hex to DEC
                    let cleanSerialNumber = serialNumber.replace(/:/g, "");
                    serialDecNumber = parseInt(cleanSerialNumber, 16);
                    console.log('Serial Number: ' + serialDecNumber);
                });
            } catch (error) {
                console.log("Error: " + error);
            }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search