- From: OlivierLorente via GitHub <sysbot+gh@w3.org>
- Date: Wed, 13 Dec 2017 11:22:18 +0000
- To: public-web-nfc@w3.org
Would you have an example showing how to use the nfcWatchOption ? I have tried the code below but I get a "TypeError". I'm not sure if I have used the correct value for the fields url, recordType and mediaType. I have let them empty but the documentation says: "The default value "" means that no matching happens". If my understanding is correct, if I let those fields empty, no match will happen so I will not receive any notification. What shall I use to be notified whatever the url, recordType and mediaType present in the tag? I set this nfcWatchOption only for the mode, I don't want to put some filtering conditions on the other ones. Thank you ``` function readNfc() { if ('nfc' in navigator) { var nfcWatchOption = { url: "", recordType: "", mediaType: "", mode: "any" }; navigator.nfc.watch(function(message) { processMessage(message); }, nfcWatchOption) .then(() => consoleLog("Added a watch.")) .catch(err => consoleLog("Adding watch failed: " + err.name)); } else { alert('NFC API not supported.'); } } ``` -- GitHub Notification of comment by OlivierLorente Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/138#issuecomment-351362948 using your GitHub account
Received on Wednesday, 13 December 2017 11:22:20 UTC