Fork of cordova-appivo-NFC
A Cordova plugin that enables reading RFID tags using RFID/NFC Reader.
API:
-
register a listener
listen(callback,errorCallBack,dataObject)
-
read data from a block
read(callback,errorCallBack,dataObject)
-
cancel the currently registered listener/reader
cancel(callback,errorCallBack)
-
write to a block
write(callback,errorCallBack,dataObject)
-
turn on LED
turnOnLED(callback,errorCallBack,dataObject)
-
turn off LED
turnOffLED(callback,errorCallBack)
Example:
var nfc = window.plugins.NFC;
nfc.write(function(event) {
if (event.state == 'Success') {
alert("Data written Successfully!!!");
}
},
function(error){
alert(error);
},
{
Data:["newID"],
BlockToWrite:5
});
nfc.read(function(event) {
if (event.state == 'Success') {
alert("Scanned tag with data " + event.tag.data+"\n"+
"Scanned tag with UID " + event.tag.UID);
}
},
function(error){
alert(error);
},
{
ReadOnce:false,
AutoReadFromBlock:true,
BlockToRead:5
});
nfc.cancel(function(event) {
if (event.state == 'Success') {
alert("Scanned stopped");
}
},
function(error){
alert(error);
});
nfc.turnOnLED(function(event) {
if(event.state == 'Success') {
alert("LED turned ON...");
}
},
function(error){
alert(error);
},
{
Red:true,
Green:false,
Blue:false
});
nfc.turnOffLED(function(event) {
if (event.state == 'Success') {
alert("LED turned OFF...");
}
},
function(error){
alert(error);
});