GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

NDEFReadingEvent: NDEFReadingEvent() constructor

Web NFC API

Web NFC API

The **`NDEFReadingEvent()`** constructor creates a new NDEFReadingEvent object which represents events dispatched on new NFC readings obtained by NDEFReader.

## Syntax

```js-nolint
new NDEFReadingEvent(type, options)
```

### Parameters

- `type`
- : A string with the name of the event.
It is case-sensitive and browsers always set it to `reading`.
- `options`
- : An object that, _in addition of the properties defined in Event()_, can have the following properties:
- `serialNumber`
- : The serial number of the device a message was read from. It default to `""`, and can be set to `null`.
- `message`
- : An object with the following members:
- `data`
- : Contains the data to be transmitted. It can be a string, an ArrayBuffer, a TypedArray, a DataView, or an array of nested records.
- `encoding`
- : A string specifying the record's encoding.
- `id`
- : A developer-defined identifier for the record.
- `lang`
- : A valid BCP 47 language tag.
- `mediaType`
- : A valid [MIME type](/docs/Web/HTTP/Guides/MIME_types).
- `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 NDEFRecord.
- `"mime"`
- : A valid [MIME type](/docs/Web/HTTP/Guides/MIME_types).
- `"smart-poster"`
- : A smart poster as defined by the [NDEF-SMARTPOSTER](https://w3c.github.io/web-nfc/#bib-ndef-smartposter) specification.
- `"text"`
- : Text as defined by the [NDEF-TEXT](https://w3c.github.io/web-nfc/#bib-ndef-text) specification.
- `"unknown"`
- : The record type is not known.
- `"URL"`
- : A URL as defined by the [NDEF-URI](https://w3c.github.io/web-nfc/#bib-ndef-uri) specification.

### Return value

A new NDEFReadingEvent object.

## Specifications

## Browser compatibility

source: MDN Web Docs mirror · page

Cite this

"NDEFReadingEvent: NDEFReadingEvent() constructor". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/NDEFReadingEvent/NDEFReadingEvent

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·