1
+
1
2
partial interface Navigator {
2
3
readonly attribute NFC nfc;
3
4
};
@@ -6,30 +7,38 @@ interface NFC {
6
7
Promise<NFCAdapter> requestAdapter();
7
8
};
8
9
9
- interface NFCAdapter : EventTarget {
10
- attribute EventHandler onmessage;
11
- Promise<void> send (NFCMessage message, optional NFCSendOptions options);
12
- };
10
+ interface NFCAdapter {
11
+ Promise<void> pushMessage(NFCMessage message, optional NFCPushOptions options);
12
+ void cancelPush();
13
13
14
- interface NFCMessageEvent : Event {
15
- readonly attribute NFCMessage message ;
14
+ Promise<long> watch(NFCWatchOptions options, MessageCallback callback);
15
+ Promise<void> unwatch(long id) ;
16
16
};
17
17
18
- [NoInterfaceObject]
19
- interface NFCMessage {
20
- readonly attribute USVString scope;
21
- readonly attribute sequence<any> data; // (DOMString or URL or Blob or JSON)
18
+ dictionary NFCPushOptions {
19
+ NFCDeviceType target;
20
+ long timeout; // in ms, default (and max) is 10sec, UAs MAY shorten it
22
21
};
23
22
24
- typedef (DOMString or URL or Blob or JSON) NFCData ;
23
+ enum NFCPushTarget { "tag", "peer", "any" } ;
25
24
26
- enum NFCTarget {
27
- "tag",
28
- "peer",
29
- "any"
30
- };
25
+ dictionary NFCWatchOptions {
26
+ USVString url; // domain/path or URL pattern
27
+ USVString kind;
28
+ USVString type;
29
+ NFCWatchMode mode;
30
+ }
31
31
32
- dictionary NFCSendOptions {
33
- NFCTarget target;
32
+ enum NFCWatchMode { "web-only", "all" };
33
+
34
+ callback MessageCallback = void (NFCMessage message, USVString url);
35
+
36
+ dictionary NFCRecord {
37
+ NFCRecordType kind; // based on TNF + JSON
38
+ USVString type; // IANA media type, with parameters
39
+ any data; // null, string (text, url), Object (json), ArrayBuffer
34
40
};
35
41
42
+ typedef sequence<NFCRecord> NFCMessage;
43
+
44
+ enum NFCRecordType { "empty", "text", "url", "json", "opaque" };
0 commit comments