Draft
This page is not complete.
Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
This is an experimental technology
Check 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
orBufferSource
orNDEFMessageInit
. options
Optional-
ignoreRead
--Boolean
specifying whether or not to skip reading for the activated reader objects. Will be ignored ifoverwrite
isfalse
.overwrite
--Boolean
specifying whether or not existing record should be overwritten, if such exists.signal
-- optionalAbortSignal
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
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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
write | 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.