Web/API/NDEFWriter/write

From Get docs

Draft This page is not complete.


Secure contextThis feature is available only in secure contexts (HTTPS), in some or all supporting browsers.


This is an experimental technologyCheck the Browser compatibility table carefully before using this in production.


The write() method of NDEFWriter interface writes a specified message to a compatiable NFC tag.

Syntax

var sessionPromise = NDEFWriter.write(message, options);

Parameters

 message
The message to be written, either DOMString or BufferSource or NDEFMessageInit.
options Optional
;* ignoreRead -- Boolean specifying whether or not to skip reading for the activated reader objects. Will be ignored if overwrite is false.
  • overwrite -- Boolean specifying whether or not existing record should be overwritten, if such exists.
  • signal -- optional AbortSignal that allows to cancell this write operation.

Return value

A Promise that resolves with undefined when and if the message transfer is successfully completed.

Exceptions

This method doesn't throw true exceptions; instead, it rejects the returned promise, passing into it a DOMException whose name is one of the following:

AbortError
The write operation was aborted with AbortSignal passed in options.
NotAllowedError
The permission for this operation was rejected or overwrite is false and there are already records on the tag.
NotSupportedError
There is no NFC adapter compatible with Web NFC, or the available NFC adapter does not support pushing messages, or connection can not be established.
NotReadableError
The UA is not allowed to access underlying NFC adapter (e.g., due to user preference).
NetworkError
Transfer failed after it already started (e.g., the tag was removed from the reader).

Specifications

Specification Status Comment
Web NFC, write() Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

write

Experimental'

Chrome

No support No

Edge

No support No

Firefox

No support No

IE

No support No

Opera

No support No

Safari

No support No

WebView Android

No support No

Chrome Android

No support No

Firefox Android

No support No

Opera Android

No support No

Safari iOS

No support No

Samsung Internet Android

No support No

Legend

No support  
No support
Experimental. Expect behavior to change in the future.'
Experimental. Expect behavior to change in the future.