WebAPI/WebNFC: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(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...")
 
No edit summary
Line 1: Line 1:
= Preliminary scope =
== Preliminary scope ==


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


= Example =
== Example ==


   navigator.mozNfc.ndef.ontagdiscovered = function (event) {
   navigator.mozNfc.ndef.ontagdiscovered = function (event) {
Line 17: Line 17:
     });
     });
   };
   };
== Proposed API ==
  ...

Revision as of 20:56, 2 February 2012

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
   });
 };

Proposed API

 ...