Re: [web-nfc] permissions-related example in explainer encourages bad assumptions about browser behavior (#482)

You're right. This is an issue with the Permissions API hinted in the spec at https://w3c.github.io/web-nfc/#obtaining-permission.
Hopefully when https://github.com/w3c/permissions/issues/194 will be fixed, we'll be able to simply mention that user activation is required in the "request-to-use-permission" algorithm.

Note that the permissions-related example in the explainer would also work with a permission flow a la Firefox:
```js
const nfcPermissionStatus = await navigator.permissions.query({ name: "nfc" });
if (permissionStatus.state === "granted") {
  // NFC access was previously granted, so we can start NFC scanning now.
  // UPDATED: Even though it is not persisted, this state could have been granted in user session. 
  startScanning();
} else {
  // Show a "scan" button.
  document.querySelector("button").style.display = "block";
  document.querySelector("button").onclick = event => {
    // Prompt user to allow UA to send and receive info when they tap NFC devices.
    // UPDATED: User would not be prompted indeed in Firefox, but scanning would start asynchronously if success.
    startScanning();
  };
}
```



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

Received on Monday, 23 December 2019 08:03:48 UTC