AnsweredAssumed Answered

How to refer to a Cordova plugin

Question asked by Steven Cox on Sep 11, 2019
Latest reply on Sep 16, 2019 by Eugene Bychkov



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
              // assuming the first record in the message has
             // a payload that can be converted to a string.
         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?