Re: [web-nfc] Attach to navigator (#602)

Next, the question is how to attach to the `navigator`.

1. use `navigator.nfc.ndef` to represent an NDEFReader, which exposes `scan()`, `write()`, `onreading`, `onreadingerror`.
`onreading` will contain an `NDEFMessage`.

2. `navigator.nfc` to contain abortable `scan()` (which initiates NFC polling) and `ontagfound` event (basically the same what `onreading` is used for now) which presents an NDEFReader `ndef` that exposes async `read()`, `write()` [and eventually `format()` which is currently included in `write()`]. Later it could contain a control object for other NFC tech (as well as NDEFReader). Also, other events could be added later.

In both cases, `navigator.nfc` could contain  a status (`active` or `suspended` flag), and an `onvisibilitychanged` event. This is to reflect the TPAC 2020 discussion with WICG/Web Bluetooth people.

I'd vote for option 2 for a more correct and more future-proof API which is also better aligned with Andoid NFC, even if it's a bigger change than doing option 1. The current API conflates polling (scanning) and read functionality, which might be confusing to people coming from native NFC APIs.

-- 
GitHub Notification of comment by zolkis
Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/602#issuecomment-707945243 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 13 October 2020 19:00:21 UTC