blob: 91ac9782561673320b4647015003c2c0124af045 (
plain) (
tree)
|
|
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
|