window.nfcHandler = function(code) {
if ('NDEFReader' in window) {
const url = `${window.location.origin}/animals/${code}/tasks`;
const ndef = new NDEFReader();
ndef.write({
records: [{ recordType: "url", data: url }]
}).then(() => {
new FilamentNotification()
.title('Saved successfully')
.success()
.send()
}).catch(error => {
new FilamentNotification()
.title(error.toString())
.danger()
.send()
});
} else {
// for testing
setTimeout(() => {
new FilamentNotification()
.title('NDEFReader not available')
.danger()
.send()
}, 5000);
}
}
window.nfcHandler = function(code) {
if ('NDEFReader' in window) {
const url = `${window.location.origin}/animals/${code}/tasks`;
const ndef = new NDEFReader();
ndef.write({
records: [{ recordType: "url", data: url }]
}).then(() => {
new FilamentNotification()
.title('Saved successfully')
.success()
.send()
}).catch(error => {
new FilamentNotification()
.title(error.toString())
.danger()
.send()
});
} else {
// for testing
setTimeout(() => {
new FilamentNotification()
.title('NDEFReader not available')
.danger()
.send()
}, 5000);
}
}