title | short-title | slug | page-type | status | browser-compat | |
---|---|---|---|---|---|---|
NDEFReadingEvent: NDEFReadingEvent() constructor |
NDEFReadingEvent() |
Web/API/NDEFReadingEvent/NDEFReadingEvent |
web-api-constructor |
|
api.NDEFReadingEvent.NDEFReadingEvent |
{{securecontext_header}}{{APIRef()}}{{SeeCompatTable}}
The NDEFReadingEvent()
constructor creates a new {{domxref("NDEFReadingEvent")}} object which represents events dispatched on new NFC readings obtained by {{DOMxRef("NDEFReader")}}.
new NDEFReadingEvent(type, options)
-
type
- : A string with the name of the event.
It is case-sensitive and browsers always set it to
reading
.
- : A string with the name of the event.
It is case-sensitive and browsers always set it to
-
options
-
: An object that, in addition of the properties defined in {{domxref("Event/Event", "Event()")}}, can have the following properties:
-
serialNumber
{{optional_inline}}- : The serial number of the device a message was read from. It default to
""
, and can be set tonull
.
- : The serial number of the device a message was read from. It default to
-
message
-
: An object with the following members:
-
data
{{optional_inline}}- : Contains the data to be transmitted. It can be a string object or literal, an {{jsxref("ArrayBuffer")}}, a {{jsxref("TypedArray")}}, a {{jsxref("DataView")}}, or an array of nested records.
-
encoding
{{optional_inline}}- : A string specifying the record's encoding.
-
id
{{optional_inline}}- : A developer-defined identifier for the record.
-
lang
{{optional_inline}}- : A valid language tag according to {{RFC(5646, "Tags for Identifying Languages (also known as BCP 47)")}}.
-
mediaType
{{optional_inline}}- : A valid MIME type.
-
recordType
-
: A string indicating the type of data stored in
data
. It must be one of the following values:-
"absolute-url"
An absolute URL to the data.
"empty"
- : An empty {{domxref("NDEFRecord")}}.
-
"mime"
- : A valid MIME type.
-
"smart-poster"
- : A smart poster as defined by the NDEF-SMARTPOSTER specification.
-
"text"
- : Text as defined by the NDEF-TEXT specification.
-
"unknown"
- : The record type is not known.
-
"URL"
- : A URL as defined by the NDEF-URI specification.
-
-
-
-
-
-
A new {{domxref("NDEFReadingEvent")}} object.
{{Specifications}}
{{Compat}}