Skip to content

Latest commit

 

History

History
79 lines (57 loc) · 2.78 KB

File metadata and controls

79 lines (57 loc) · 2.78 KB
title short-title slug page-type status browser-compat
NDEFReadingEvent: NDEFReadingEvent() constructor
NDEFReadingEvent()
Web/API/NDEFReadingEvent/NDEFReadingEvent
web-api-constructor
experimental
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")}}.

Syntax

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 {{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 to null.
      • 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}}

          • 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"

              • "smart-poster"

              • "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.

Return value

A new {{domxref("NDEFReadingEvent")}} object.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}