Add NFC tag writing functionality to ChoreCard component, Add Email to sign up

This commit is contained in:
Mo Tarbin 2024-07-05 17:28:47 -04:00
parent 71bad5a19f
commit c34da50c8c
4 changed files with 93 additions and 10 deletions

18
src/service/NFCWriter.jsx Normal file
View file

@ -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