我想用javascript/Android下的NFC阅读器读取RFID标签的UID。
UID由制造商设置,这样您就不能复制RFID卡。
我使用navigator.nfc读取NFC信息,但是当我点击RFID卡时,产生的名为message的对象有一个名为records的数组,其中只有一个成员:message.records[0]
在message.records[0]内部,有3个字段:data = null,mediaType = empty string,recordType = "empty"。
UID在哪里?
当我使用TagInfo应用程序时,我获得了关于RFID卡的所有信息,包括协议信息中的UID。所以NFC阅读器能够获取它们。为什么不使用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.');
}
}发布于 2019-05-03 20:16:01
基于您使用navigator.nfc.watch()的事实,我假设您尝试使用Web NFC API,或者更确切地说,使用它的previous versions之一。
Web NFC API仅限于NFC论坛标签上的NDEF消息。您不能访问NDEF抽象层以下的任何协议参数。因此,目前无法使用该API读取标记的UID。
https://stackoverflow.com/questions/55955868
复制相似问题