NDEFReader.write()
Draft
This page is not complete.
Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Experimental
This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The write()
method of NDEFReader
interface writes a
specified message to a compatible NFC tag.
Syntax
var sessionPromise = NDEFReader.write(message, options);
Parameters
message
- The message to be written, either
DOMString
orBufferSource
orNDEFMessageInit
. options
Optional-
overwrite
--Boolean
specifying whether or not existing record should be overwritten, if such exists.signal
-- optionalAbortSignal
that allows to cancel 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
isfalse
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
BCD tables only load in the browser