6
6
- Francois Beaufort
7
7
8
8
Participate
9
- - https://github.com/w3c/web-nfc/issues/
9
+ - https://github.com/w3c/web-nfc/issues/
10
10
- https://lists.w3.org/Archives/Public/public-web-nfc/
11
11
12
12
## Introduction
@@ -93,14 +93,14 @@ info when users tap NFC devices can be done smoothly once permission is granted.
93
93
94
94
``` js
95
95
const reader = new NDEFReader ();
96
-
96
+
97
97
async function startScanning () {
98
98
await reader .scan ();
99
99
reader .onreading = event => {
100
100
/* handle NDEF messages */
101
101
};
102
102
}
103
-
103
+
104
104
const nfcPermissionStatus = await navigator .permissions .query ({ name: " nfc" });
105
105
if (permissionStatus .state === " granted" ) {
106
106
// NFC access was previously granted, so we can start NFC scanning now.
@@ -123,7 +123,7 @@ USB](https://wicg.github.io/webusb/) in that it offers secure low level access
123
123
with no magic and instead exposes data as a DataView as well as requires text to
124
124
be encoded and decoded using TextEncoder/TextDecoder, which allows handling
125
125
cases where the text might even be in UTF-16 do to existing real life
126
- implementations.
126
+ implementations.
127
127
128
128
``` js
129
129
const reader = new NDEFReader ();
@@ -162,13 +162,12 @@ const abortController = new AbortController();
162
162
abortController .signal .onabort = event => {
163
163
// All NFC operations have been aborted.
164
164
};
165
-
166
- const reader = new NDEFReader ();
167
- await reader .scan ({ signal: abortController .signal });
168
-
169
- const writer = new NDEFWriter ();
170
- await writer .push (" foo" , { signal: abortController .signal });
171
-
165
+
166
+ const ndef = new NDEFReader ();
167
+ await ndef .scan ({ signal: abortController .signal });
168
+
169
+ await ndef .push (" foo" , { signal: abortController .signal });
170
+
172
171
document .querySelector (" #abortButton" ).onclick = event => {
173
172
abortController .abort ();
174
173
};
@@ -234,7 +233,7 @@ The reader and writer objects could have been merged into one single object, but
234
233
as we allow multiple scans with filters to be active at the same time (maybe in
235
234
multiple places/view of the app/site) then it makes more sense to be able to use
236
235
separate objects.
237
-
236
+
238
237
## Considered alternatives
239
238
240
239
### Restrict to NDEF and name accordingly
0 commit comments