canmove, Confirmed users
725
edits
No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
** Discovered NDEF tags are automatically parsed and dispatched to content in the "tagdiscovered" event on navigator.mozNfc.ndef. | ** Discovered NDEF tags are automatically parsed and dispatched to content in the "tagdiscovered" event on navigator.mozNfc.ndef. | ||
** navigator.mozNfc only available to a specific privileged content page (cf. WebTelephony, WebSMS). | ** navigator.mozNfc only available to a specific privileged content page (cf. WebTelephony, WebSMS). | ||
** For now, content is expected to do filtering and dispatching to handlers e.g. via WebIntents | ** For now, content is expected to do filtering and dispatching to handlers e.g. via WebIntents/WebActions. | ||
== Proposed API == | == Proposed API == | ||
Line 63: | Line 50: | ||
readonly attribute DOMString payloadText; | readonly attribute DOMString payloadText; | ||
readonly attribute ArrayBuffer payloadArrayBuffer; | readonly attribute ArrayBuffer payloadArrayBuffer; | ||
}; | |||
== 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 | |||
// Could dispatch event.message here to other web apps based on MIME type, URI, etc. | |||
}); | |||
}; | }; | ||