Hi,
I'm doing some testing of cordova plugins, in particular the nfc scanner.
$native> ../cordova install phonegap-nfc
I'm trying to run a quick test, something like the sample code:
nfc.addNdefListener (
function (nfcEvent) {
var tag = nfcEvent.tag,
ndefMessage = tag.ndefMessage;
// dump the raw json of the message
// note: real code will need to decode
// the payload from each record
alert(JSON.stringify(ndefMessage));
// assuming the first record in the message has
// a payload that can be converted to a string.
alert(nfc.bytesToString(ndefMessage[0].payload).substring(3));
},
function () { // success callback
alert("Waiting for NDEF tag");
},
function (error) { // error callback
alert("Error adding NDEF listener " + JSON.stringify(error));
}
);
but I need to define the 'nfc' object within a view.
I assume I should use the format similar to:
const nfc = require('%app.core%/nfc')
but I'm not sure that's correct. Also, what is the best method to determine what the 'require' should be for any plugin?
Thanks