NDEFReader

@JSGlobal("NDEFReader") @native @JSType
class NDEFReader() extends EventTarget

The NDEFReader interface of the Web NFC API (https://developer.mozilla.org/en-US/docs/Web/API/Web_NFC_API) is used to read from and write data to compatible NFC devices, e.g. NFC tags supporting NDEF, when these devices are within the reader's magnetic induction field.

See also:
class Object
trait Any
class Object
trait Matchable
class Any

Value members

Concrete methods

def scan(options: NDEFScanOptions): Promise[Unit]

Activates a reading device and returns a Promise that either resolves when an NFC tag read operation is scheduled or rejects if a hardware or permission error is encountered. This method triggers a permission prompt if the "nfc" permission has not been previously granted.

Activates a reading device and returns a Promise that either resolves when an NFC tag read operation is scheduled or rejects if a hardware or permission error is encountered. This method triggers a permission prompt if the "nfc" permission has not been previously granted.

Returns:

a Promise that resolves immediately after scheduling read operations for the NFC adapter.

def write(message: String, options: NDEFWriteOptions): Promise[Unit]

Attempts to write an NDEF message to a tag and returns a Promise that either resolves when a message has been written to the tag or rejects if a hardware or permission error is encountered. This method triggers a permission prompt if the "nfc" permission has not been previously granted.

Attempts to write an NDEF message to a tag and returns a Promise that either resolves when a message has been written to the tag or rejects if a hardware or permission error is encountered. This method triggers a permission prompt if the "nfc" permission has not been previously granted.

Value parameters:
message

The message to be written, either a string object or literal, an ArrayBuffer, a TypedArray, a DataView, or an array of records. A record has the following members:

options

An object with the following properties:

Returns:

a Promise that either resolves when a message has been written to the tag or rejects if a hardware or permission error is encountered.

def write(message: ArrayBuffer, options: NDEFWriteOptions): Promise[Unit]
def write(message: TypedArray[_, _], options: NDEFWriteOptions): Promise[Unit]
def write(message: DataView, options: NDEFWriteOptions): Promise[Unit]
def write(message: Array[NDEFRecord], options: NDEFWriteOptions): Promise[Unit]
def write(message: String): Promise[Unit]
def write(message: ArrayBuffer): Promise[Unit]
def write(message: DataView): Promise[Unit]
def write(message: Array[NDEFRecord]): Promise[Unit]

Inherited methods

def addEventListener[T <: Event](`type`: String, listener: Function1[T, _], options: EventListenerOptions): Unit

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

This implementation accepts a settings object of type EventListenerOptions.

Inherited from:
EventTarget
def addEventListener[T <: Event](`type`: String, listener: Function1[T, _], useCapture: Boolean): Unit

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

Inherited from:
EventTarget
def dispatchEvent(evt: Event): Boolean

Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) apply to events dispatched manually with dispatchEvent().

Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) apply to events dispatched manually with dispatchEvent().

Inherited from:
EventTarget
def hasOwnProperty(v: String): Boolean
Inherited from:
Object
def isPrototypeOf(v: Object): Boolean
Inherited from:
Object
def propertyIsEnumerable(v: String): Boolean
Inherited from:
Object
def removeEventListener[T <: Event](`type`: String, listener: Function1[T, _], options: EventListenerOptions): Unit

Removes the event listener previously registered with EventTarget.addEventListener.

Removes the event listener previously registered with EventTarget.addEventListener.

This implementation accepts a settings object of type EventListenerOptions.

Inherited from:
EventTarget
def removeEventListener[T <: Event](`type`: String, listener: Function1[T, _], useCapture: Boolean): Unit

Removes the event listener previously registered with EventTarget.addEventListener.

Removes the event listener previously registered with EventTarget.addEventListener.

Inherited from:
EventTarget
def toLocaleString(): String
Inherited from:
Object
def valueOf(): Any
Inherited from:
Object

Concrete fields

var onreading: Function1[NDEFReadingEvent, Any]

The reading event of the NDEFReader interface is fired whenever a new reading is available from compatible NFC devices (e.g. NFC tags supporting NDEF) when these devices are within the reader's magnetic induction field.

The reading event of the NDEFReader interface is fired whenever a new reading is available from compatible NFC devices (e.g. NFC tags supporting NDEF) when these devices are within the reader's magnetic induction field.

var onreadingerror: Function1[Event, Any]

The readingerror event of the NDEFReader interface is fired whenever an error occurs during reading of NFC tags, e.g. when tags leave the reader's magnetic induction field.

The readingerror event of the NDEFReader interface is fired whenever an error occurs during reading of NFC tags, e.g. when tags leave the reader's magnetic induction field.