aboutsummaryrefslogtreecommitdiffstats
path: root/src/service
diff options
context:
space:
mode:
authorLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-05 17:28:47 -0400
committerLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-05 17:28:47 -0400
commitc34da50c8c1564c9c6556522bf12a93639c1f160 (patch)
tree22690c5d8efe866f3f97bf479115d6914f579824 /src/service
parent71bad5a19f8aea358b3f21dde4f69fd53a870184 (diff)
downloaddonetick-frontend-c34da50c8c1564c9c6556522bf12a93639c1f160.tar.gz
donetick-frontend-c34da50c8c1564c9c6556522bf12a93639c1f160.tar.bz2
donetick-frontend-c34da50c8c1564c9c6556522bf12a93639c1f160.zip
Add NFC tag writing functionality to ChoreCard component, Add Email to sign up
Diffstat (limited to '')
-rw-r--r--src/service/NFCWriter.jsx18
1 files changed, 18 insertions, 0 deletions
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