NDEFReader.write() - Web APIs 编辑
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 compatiable NFC tag.
Syntax
var sessionPromise = NDEFReader.write(message, options);
Parameters
-
message
- The message to be written, either
DOMString
orBufferSource
orNDEFMessageInit
. options
OptionalignoreRead
--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. |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论