Back to Content

NDEFMessage: NDEFMessage() constructor

files/en-us/web/api/ndefmessage/ndefmessage/index.md

latest1.8 KB
Original Source

{{SecureContext_Header}}{{APIRef("Web NFC API")}}{{SeeCompatTable}}

The NDEFMessage() constructor creates a new {{domxref("NDEFMessage")}} object, initialized with the given NDEF records.

Syntax

js-nolint
new NDEFMessage(records)

Parameters

  • records
    • : An array of objects with the following members:
      • data {{optional_inline}}
        • : Contains the data to be transmitted; one of a string, 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 {{glossary("BCP 47 language tag")}}.
      • 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.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}