Re: [web-nfc] Handling non-formatted tags (#367)

The current scope of Web NFC is NDEF-only.

Adding an explicit use case and API for detecting tags, available tech, formatting etc would be new features.

So far that has not been in Web NFC scope and it's not in the use cases at the moment. There was a shift when more and more low-level stuff was added and that made the spec inconsistent, so yes these features are missing.

At the moment, handling non-formatted (NDEF) tags is covered by policy, not by an explicit API so that apps could implement that policy. **_Apps are currently not supposed to make an action like explicitly formatting a tag via Web NFC._**

Apps can only read and write a tag at the moment. However, we can cover the non-formatted use cases by policies.

> Specifying an event that is fired when an unformatted is presented while scanning.

That is easily possible. Is a message with empty record array good enough for that as suggested [above](https://github.com/w3c/web-nfc/issues/367#issuecomment-540680477)?

> Adding an option to push() that allows a site to detect when there is already data on a card (in any format?) and prevent overwriting it.

OK, let's call it the `overwrite` flag here.

It's hard to define what do we _guarantee_ to work and what do we mean by overwrite. It also depends on the underlying platform and the tag itself, what the implementation is allowed to do, so it would not be fortunate promising to an app the semantics of overwrite. We need to specify exactly what policy we expect. For instance like this:

If a push is set up, and a tag comes in range, implementations could do the following:
- if not NDEF-formatted, but it is NDEF-formattable, then format + write (this may fail).
- if the tag is NDEF-formatted and the `overwrite` flag is on, do the write, otherwise fail
- (future) if the tag uses other tech that Web NFC supports and can write, and if the `overwrite` flag is on, do the write/transceive, otherwise fail 
- otherwise fail.

The above would work without the `overwrite` flag as well, but we could have it as app-defined hint.

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

Received on Thursday, 10 October 2019 18:19:14 UTC