forked from status-im/status-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnfc.cljs
More file actions
26 lines (22 loc) · 872 Bytes
/
nfc.cljs
File metadata and controls
26 lines (22 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(ns status-im.ui.components.nfc
(:require [status-im.utils.platform :as platform]
[status-im.react-native.js-dependencies :as js-dependencies]))
(def android-only-error "NFC API is available only on Android")
(defn get-card-id [on-success on-error]
(if platform/android?
(-> (.getCardId js-dependencies/nfc)
(.then on-success)
(.catch on-error))
(on-error android-only-error)))
(defn read-tag [sectors on-success on-error]
(if platform/android?
(-> (.readTag js-dependencies/nfc (clj->js sectors))
(.then on-success)
(.catch on-error))
(on-error android-only-error)))
(defn write-tag [sectors card-id on-success on-error]
(if platform/android?
(-> (.writeTag js-dependencies/nfc (clj->js sectors) card-id)
(.then on-success)
(.catch on-error))
(on-error android-only-error)))