Polymer 2 Web Component for NFC reading and writing using WebNFC W3C Draft Standard.
bower install --save polymer-nfc
Import it:
<link rel="import" href="../bower_components/polymer-nfc/polymer-nfc.html">
Use it:
<polymer-nfc data={{nfcData}}></polymer-nfc>
You can also turn reading on and off in two ways:
- Add a boolean watch attribute and bind it to a local variable
<polymer-nfc watch={{flag}} data={{nfcData}}></polymer-nfc>
- Using javascript
this.$.nfc.readOn();
this.$.nfc.readOff();
You can also write data to a NFC Tag. For this to work, your data must be a valid json object. You'll need to explicitly turn writng on, and provide the data via the data data binding:
this.$.nfc.writeOn();
var nfcData = {someId: 1, someValue:"WebNFC rulez!"};
After a successful write, write mode is automatically turned off. If there's an error, the component keeps writing enabled, waiting for a new attempt.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D