Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
Set NDEF message on Android Chrome

I would like to set an NDEF message on my website if it is opened from android chrome and read it with an NFC Reader using nfcpy.

According to https://developer.mozilla.org/en-US/docs/Web/API/NDEFMessage/NDEFMessage I think I should be able to do this.

My page looks like this:

<button onclick="set_ndef()">Set NDEF msg</button>
<pre id="log"></pre>

<script>
async function set_ndef() {
  if ("NDEFReader" in window) {
    try {
      const ndefmsg = new NDEFMessage({'records': [{'recordType': 'text', 'data': 'asd'}]});
      consoleLog(ndefmsg)
    } catch(error) {
      consoleLog(error);
    }
  } else {
    consoleLog("Web NFC is not supported.");
  }
}

function consoleLog(data) {
    var logElement = document.getElementById('log');
    logElement.innerHTML += data + '\n';
}
</script>

The website uses HTTPS, and when I press the button an NDEFRecord object is printed into the div.

I have an acr122u NFC reader, which I was able to set up using nfcpy:

import nfc
import time    

def on_connect(tag):
    print(tag.identifier.hex())
    tag_ident = tag.identifier.hex()[:8]
    print(tag.ndef)
    if tag.ndef:
        for record in tag.ndef:
            print(record)
    return True


while True:
    with nfc.ContactlessFrontend('usb') as clf:
        tag = clf.connect(rdwr={'on-connect': on_connect, 'beep-on-connect': True})
    time.sleep(1)

After I place my phone on the reader (after pressing the button on the page) I am only able to read the UID of the phone, but the tag.ndef is None

How can I do this (if I am even able to)?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

https://stackoverflow.com/a/65659726/2373819 should give you some background as why this won't work, Android Chrome NFC is an NFC reader and 2 readers won't work.

Though with the acr122u NFC reader can usually be configure to behave as an NFC Tag, then Android Chrome should be able read and write NDEF messages to it (https://nfcpy.readthedocs.io/en/latest/topics/get-started.html#emulate-a-card)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!