From c34da50c8c1564c9c6556522bf12a93639c1f160 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Fri, 5 Jul 2024 17:28:47 -0400 Subject: Add NFC tag writing functionality to ChoreCard component, Add Email to sign up --- src/service/NFCWriter.jsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/service/NFCWriter.jsx (limited to 'src/service') diff --git a/src/service/NFCWriter.jsx b/src/service/NFCWriter.jsx new file mode 100644 index 0000000..91ac978 --- /dev/null +++ b/src/service/NFCWriter.jsx @@ -0,0 +1,18 @@ +const writeToNFC = async url => { + if ('NDEFReader' in window) { + try { + const ndef = new window.NDEFReader() + await ndef.write({ + records: [{ recordType: 'url', data: url }], + }) + alert('URL written to NFC tag successfully!') + } catch (error) { + console.error('Error writing to NFC tag:', error) + alert('Error writing to NFC tag. Please try again.') + } + } else { + alert('NFC is not supported by this browser.') + } +} + +export default writeToNFC -- cgit