Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda