From db34edec467354b05b80f9fac8ab739827d4af51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?=
}
};
-reader.start();
+reader.scan();
@@ -773,7 +773,7 @@
const reader = new NFCReader({url: "https://mygame.com/mypath/mygame"}); -reader.start(); +reader.scan(); reader.onreading = async event => { console.log(`Source: ${ event.message.url }`); console.log(`Game state: ${ JSON.stringify(event.message.records) }`); @@ -809,7 +809,7 @@} }); -reader.start(); +reader.scan(); const writer = new NFCWriter(); writer.push({ @@ -849,7 +849,7 @@
console.log("=== data ===\n" + record.toText()); } }; -reader.start(); +reader.scan(); const writer = new NFCWriter(); writer.push("Pushing data is fun!", {target: "tag", ignoreRead: false}); @@ -1664,8 +1664,7 @@
The NDEFRecordType string
attribute EventHandler onreading; attribute EventHandler onerror; - void start(); - void stop(); + void scan(optional NFCScanOptions options={}); }; [Constructor(DOMString type, NFCReadingEventInit readingEventInitDict), SecureContext, Exposed=Window] @@ -2110,6 +2109,18 @@The NFCReaderOptions dictionary
++ The NFCScanOptions dictionary
++ dictionary NFCScanOptions { + AbortSignal? signal; + }; +++ The signal property allows to abort + the scan() operation. +
+- Writing or pushing content
@@ -2969,7 +2980,7 @@
Writing or pushing content
In order to receive NFC content, the client needs to attach an event listener for the "`reading`" event on an {{NFCReader}} instance and then activate it by calling - NFCReader.start(). + NFCReader.scan().Each {{NFCReader}} can filter the NFC content based on @@ -3110,23 +3121,27 @@
Writing or pushing content
The start() method
+- The scan() method
The section [[[#steps-receiving]]] uses {{NFCReader}} instances to match incoming NFC content.
- Multiple consecutive calls to the start() + Multiple consecutive calls to the scan() method from the same origin create filters which are in OR relationship.
- When the NFCReader.start method is invoked, the UA + When the NFCReader.scan method is invoked, the UA MUST run the following NFC listen algorithm:
+
- Let |reader:NFCReader| be the {{NFCReader}} instance.
+- + Let |signal:AbortSignal| be the |options|’ dictionary member + of the same name if present, or `null` otherwise. +
- If there is no underlying NFC Adapter, or if a connection cannot be established, then @@ -3163,6 +3178,22 @@
Writing or pushing content
+ If |signal|’s [= AbortSignal/aborted flag =] is set, then return. + ++ If |signal| is not `null`, then + add the following abort steps to |signal|: + +
+- + Remove the {{NFCReader}} instance from the activated reader objects. +
+- + If the activated reader objects [= list/is empty =], then make a request + to stop listening to NDEF messages on all NFC adapters. +
+Run the following steps in parallel: - The stop() method
-- When the NFCReader.stop method is invoked, the UA - MUST run the following algorithm: -
-
- -- - Remove the {{NFCReader}} instance from the activated reader objects. -
-- - If the activated reader objects [= list/is empty =], then make a request - to stop listening to NDEF messages on all NFC adapters. -
-