GoogleChrome / samples

A repo containing samples tied to new functionality in each release of Google Chrome.
https://www.chromestatus.com/samples
Apache License 2.0
5.79k stars 2.38k forks source link

How to get plain text from NDEF Record object? #732

Closed XxCodoxX closed 3 years ago

XxCodoxX commented 3 years ago

I use this example https://googlechrome.github.io/samples/web-nfc/ and I have a question about how do I get plain text from "log(> Records: (${message.records.length}));" this code

beaufortfrancois commented 3 years ago

See https://web.dev/nfc/#read-and-write-a-text-record

  const textDecoder = new TextDecoder(record.encoding);
  console.log(`Text: ${textDecoder.decode(record.data)} (${record.lang})`);