If you need the tag id, nfc.addTagDiscoveredListener() is good. Starting from phonegap-nfc-0.4.0, the tag ID is also included when the NDEF listener is available Inside.
You can convert id to hexadecimal string to display with nfc.bytesToHexString(tag.id)
function ready() {
function onNfc(nfcEvent) {
var tag = nfcEvent.tag;
var tagId = nfc.bytesToHexString(tag.id);< br /> alert(tagId);
}
function win() {
console.log("Listening for NFC Tags");
}
function fail(error) {
alert("Error adding NFC listener");
}
nfc.addTagDiscoveredListener( onNfc, win, fail);
}
function init() {
document.addEventListener('deviceready', ready, false);
}
I want to read the UID of an NFC tag, the tag does not have any ndef message or anything (empty), just the UID. It is easy to do on Android, but Phonegap development is faster, So I want to know if it is possible to use Phonegap, possibly using the phonegap-nfc plugin.
The phonagap-nfc plugin will allow you to read the UID of the tag.
If you need the tag ID, nfc.addTagDiscoveredListener() is good. Starting from phonegap-nfc-0.4.0, the tag ID is also included when the NDEF listener is available.
You can Convert id to hexadecimal string to display with nfc.bytesToHexString(tag.id)
function ready() {
function onNfc(nfcEvent) {
var tag = nfcEvent.tag;
var tagId = nfc.bytesToHexString(tag.id);
alert(tagId);
}
function win() {
console.log("Listening for NFC Tags");
}
function fail( error) {
alert("Error adding NFC listener");
}
nfc.addTagDiscoveredListener(onNfc, win, fail);
}
function init() {
document.addEventListener('deviceready', ready, false);
}