I want to read UID of an RFID tag with the NFC reader under javascript/Android.
The UID is set by manufacturer so that you can't copy the RFID card.
I use navigator.nfc
to read NFC information but when I tap a RFID card, the resulting object called message has an array called records with only one member: message.records[0]
Inside message.records[0]
, there are 3 fields: data = null
, mediaType = empty string
, recordType = "empty"
.
Where is the UID?
When I use the TagInfo application, I get all information about the RFID card including the UID in the protocol information. So NFC reader is able to get them. Why not navigator.nfc
?
function readWriteNfc() {
if ('nfc' in navigator) {
navigator.nfc.watch(function (message) {
consoleLog("NFC message received from URL " + message);
//now message.records[0].data is null...
}, {mode: 'any'})
.then(() => consoleLog("Added a watch."))
.catch(err => consoleLog("Adding watch failed: " + err.name));
} else {
consoleLog('NFC API not supported.');
}
}