@spencerls/react-native-nfc 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @spencer/nfc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An easy, clean, React-friendly NFC service built on `react-native-nfc-manager`.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -19,25 +19,26 @@ React Native 0.74+ or Expo (Bare / Prebuild)
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
|
-
import {
|
|
22
|
+
import { nfc } from "@spencer/nfc";
|
|
23
|
+
import { Ndef, NfcAdapter } from "react-native-nfc-manager";
|
|
23
24
|
|
|
24
25
|
export default function Example() {
|
|
25
|
-
const {
|
|
26
|
+
const { nfcState } = useNfc();
|
|
26
27
|
|
|
27
28
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
+
nfc.service.startReader(
|
|
29
30
|
NfcAdapter.FLAG_READER_NFC_V | NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS,
|
|
30
31
|
async (tag) => {
|
|
31
32
|
console.log("Tag:", tag);
|
|
32
|
-
await
|
|
33
|
-
await
|
|
33
|
+
await nfc.service.stopReader();
|
|
34
|
+
await nfc.service.writeNdef([Ndef.textRecord("Hello NFC!")]);
|
|
34
35
|
}
|
|
35
36
|
);
|
|
36
37
|
|
|
37
|
-
return () =>
|
|
38
|
+
return () => nfc.service.stopReader();
|
|
38
39
|
}, []);
|
|
39
40
|
|
|
40
|
-
return <Text>NFC state: {
|
|
41
|
+
return <Text>NFC state: {nfcState}</Text>;
|
|
41
42
|
}
|
|
42
43
|
```
|
|
43
44
|
|
package/package.json
CHANGED