Add NFC tag writing functionality to ChoreCard component, Add Email to sign up
This commit is contained in:
parent
71bad5a19f
commit
c34da50c8c
4 changed files with 93 additions and 10 deletions
18
src/service/NFCWriter.jsx
Normal file
18
src/service/NFCWriter.jsx
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue