WebAPI/WebNFC

From MozillaWiki
< WebAPI
Revision as of 20:55, 2 February 2012 by Philikon (talk | contribs) (Created page with "= Preliminary scope = * explicitly NDEF-only for now (navigator.mozNfc.ndef), other technologies to be investigated * read-only, no tag creation * dispatch all discovered NDEF t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Preliminary scope

  • explicitly NDEF-only for now (navigator.mozNfc.ndef), other technologies to be investigated
  • read-only, no tag creation
  • dispatch all discovered NDEF tags to the "tagdiscovered" event, privileged web app does filtering and dispatches e.g. via WebIntents.

Example

 navigator.mozNfc.ndef.ontagdiscovered = function (event) {
   console.log("Discovered an NDEF message with " + event.message.records.length + " records.");
   event.message.records.forEach(function (record) {
     console.log("Found a " + record.tnf + " record" +
                 " of type " + record.type +
                 " with ID " + record.id +
                 " and payload " + record.payloadText);
     // record.payloadArrayBuffer is an typed array representation of the payload
   });
 };