Skip to content

Web Component for NFC reading and writing using WebNFC W3C Draft Standard.

License

Notifications You must be signed in to change notification settings

freudFlintstone/polymer-nfc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polymer-NFC

Polymer 2 Web Component for NFC reading and writing using WebNFC W3C Draft Standard.

Installation

bower install --save polymer-nfc

Usage

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.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT License

About

Web Component for NFC reading and writing using WebNFC W3C Draft Standard.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages