@spencerls/react-native-nfc 1.0.10 → 1.0.11
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/API.md +234 -94
- package/README.md +155 -150
- package/dist/index.d.mts +53 -62
- package/dist/index.d.ts +53 -62
- package/dist/index.js +440 -281
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +435 -281
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,19 +6,17 @@ A clean, React-friendly, **cross-platform** NFC layer built on top of
|
|
|
6
6
|
## 🎯 Truly Cross-Platform
|
|
7
7
|
|
|
8
8
|
Write your NFC code once and it works on **both iOS and Android**.
|
|
9
|
-
|
|
10
|
-
Everything else—reading, writing, and all NFC operations—uses the exact same API.
|
|
9
|
+
All NFC operations use the exact same API across platforms.
|
|
11
10
|
|
|
12
11
|
This package provides:
|
|
13
12
|
|
|
14
|
-
- A unified NFC service (`nfcService`)
|
|
13
|
+
- A unified NFC service with job-based architecture (`nfcService`)
|
|
15
14
|
- High-level protocol namespaces (`nfc.tag`, `nfc.v`, `nfc.ndef`)
|
|
16
15
|
- Low-level tag modules (`nfcTag`, `nfcVTag`, `nfcNdefTag`)
|
|
17
|
-
-
|
|
18
|
-
- Safe Android reader handling
|
|
19
|
-
- Optional React hooks and provider
|
|
16
|
+
- React hooks for one-shot and continuous NFC sessions
|
|
20
17
|
- Technology sessions for NDEF/NfcV and raw commands
|
|
21
18
|
- Builder pattern for NDEF records
|
|
19
|
+
- Automatic session management and cleanup
|
|
22
20
|
|
|
23
21
|
The API is designed to be stable, predictable, and easy to use across iOS and Android.
|
|
24
22
|
|
|
@@ -28,15 +26,13 @@ The API is designed to be stable, predictable, and easy to use across iOS and An
|
|
|
28
26
|
|
|
29
27
|
| Feature | iOS | Android |
|
|
30
28
|
|---------|-----|---------|
|
|
31
|
-
|
|
|
29
|
+
| Technology Sessions | ✅ | ✅ |
|
|
30
|
+
| Tag Event Handling | ✅ | ✅ |
|
|
32
31
|
| NDEF Read/Write | ✅ | ✅ |
|
|
33
32
|
| NFC-V (ISO15693) | ✅ | ✅ |
|
|
34
|
-
| Technology Sessions | ✅ | ✅ |
|
|
35
33
|
| React Hooks | ✅ | ✅ |
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
**Platform-specific code:** Only `enableReaderMode_ANDROID()` is Android-specific (no-op on iOS).
|
|
39
|
-
All other APIs work identically on both platforms.
|
|
35
|
+
**100% Cross-Platform** - All APIs work identically on both platforms.
|
|
40
36
|
|
|
41
37
|
---
|
|
42
38
|
|
|
@@ -56,32 +52,46 @@ Works with:
|
|
|
56
52
|
|
|
57
53
|
---
|
|
58
54
|
|
|
59
|
-
##
|
|
55
|
+
## Quick Start
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
import { useNfc, useNfcState, nfcService } from "@spencerls/react-native-nfc";
|
|
63
|
-
import { NfcAdapter } from "react-native-nfc-manager";
|
|
57
|
+
### One-Shot Tag Read
|
|
64
58
|
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
```tsx
|
|
60
|
+
import { useNfcTech, nfcTag } from "@spencerls/react-native-nfc";
|
|
61
|
+
import { NfcTech } from "react-native-nfc-manager";
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
export default function ScanButton() {
|
|
64
|
+
const { startTech } = useNfcTech(
|
|
65
|
+
[NfcTech.Ndef, NfcTech.NfcV],
|
|
66
|
+
async () => {
|
|
67
|
+
const tag = await nfcTag.getTag();
|
|
68
|
+
console.log("Tag ID:", tag.id);
|
|
69
|
+
}
|
|
73
70
|
);
|
|
74
71
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
return <Button title="Scan NFC" onPress={startTech} />;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Continuous Tag Scanning
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { useNfcTechLoop, nfcTag } from "@spencerls/react-native-nfc";
|
|
80
|
+
import { NfcTech } from "react-native-nfc-manager";
|
|
81
|
+
|
|
82
|
+
export default function ContinuousScanScreen() {
|
|
83
|
+
const { start, stop, isRunning } = useNfcTechLoop(
|
|
84
|
+
[NfcTech.Ndef, NfcTech.NfcV],
|
|
85
|
+
async () => {
|
|
86
|
+
const tag = await nfcTag.getTag();
|
|
87
|
+
console.log("Tag detected:", tag.id);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
81
90
|
|
|
82
91
|
return (
|
|
83
92
|
<View>
|
|
84
|
-
<
|
|
93
|
+
<Button title={isRunning ? "Stop" : "Start"} onPress={isRunning ? stop : start} />
|
|
94
|
+
<Text>Status: {isRunning ? "Scanning..." : "Idle"}</Text>
|
|
85
95
|
</View>
|
|
86
96
|
);
|
|
87
97
|
}
|
|
@@ -89,185 +99,177 @@ export default function ScannerScreen() {
|
|
|
89
99
|
|
|
90
100
|
---
|
|
91
101
|
|
|
92
|
-
##
|
|
102
|
+
## High-Level Operations
|
|
103
|
+
|
|
104
|
+
### Get Basic Tag Information
|
|
105
|
+
|
|
106
|
+
**Cross-platform:** Works identically on iOS and Android.
|
|
93
107
|
|
|
94
108
|
```tsx
|
|
95
|
-
import {
|
|
96
|
-
import {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// Platform-specific: Configure Android reader mode (no-op on iOS)
|
|
102
|
-
nfcService.enableReaderMode_ANDROID(NfcAdapter.FLAG_READER_NFC_V);
|
|
103
|
-
|
|
104
|
-
const begin = () => {
|
|
105
|
-
// Cross-platform: Works identically on iOS and Android
|
|
106
|
-
start(
|
|
107
|
-
(tag) => {
|
|
108
|
-
console.log("Tag:", tag.id);
|
|
109
|
-
},
|
|
110
|
-
{ cooldownMs: 1200 }
|
|
111
|
-
);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
return <Button title="Start" onPress={begin} />;
|
|
115
|
-
}
|
|
109
|
+
import { nfc } from "@spencerls/react-native-nfc";
|
|
110
|
+
import { NfcTech } from "react-native-nfc-manager";
|
|
111
|
+
|
|
112
|
+
const tag = await nfc.tag.getTag([NfcTech.NfcA, NfcTech.NfcV, NfcTech.Ndef]);
|
|
113
|
+
console.log("Tag ID:", tag.id);
|
|
114
|
+
console.log("Tag Type:", tag.type);
|
|
116
115
|
```
|
|
117
116
|
|
|
118
117
|
---
|
|
119
118
|
|
|
120
|
-
|
|
119
|
+
### NDEF Write with Builder
|
|
121
120
|
|
|
122
121
|
**Cross-platform:** Works identically on iOS and Android.
|
|
123
122
|
|
|
124
123
|
```tsx
|
|
125
124
|
import { nfc } from "@spencerls/react-native-nfc";
|
|
126
|
-
import { NfcTech } from "react-native-nfc-manager";
|
|
127
125
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
126
|
+
await nfc.ndef.write(
|
|
127
|
+
nfc.ndef.Builder.records((B) => [
|
|
128
|
+
B.textRecord("Hello, world!"),
|
|
129
|
+
B.uriRecord("https://www.google.com"),
|
|
130
|
+
B.jsonRecord(
|
|
131
|
+
JSON.stringify({
|
|
132
|
+
name: "John Doe",
|
|
133
|
+
age: 30,
|
|
134
|
+
email: "john.doe@example.com",
|
|
135
|
+
})
|
|
136
|
+
),
|
|
137
|
+
])
|
|
138
|
+
);
|
|
141
139
|
```
|
|
142
140
|
|
|
143
141
|
---
|
|
144
142
|
|
|
145
|
-
|
|
143
|
+
### NDEF Read
|
|
146
144
|
|
|
147
145
|
**Cross-platform:** Works identically on iOS and Android.
|
|
148
146
|
|
|
149
147
|
```tsx
|
|
150
148
|
import { nfc } from "@spencerls/react-native-nfc";
|
|
151
149
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
nfc.ndef.Builder.records((B) => [
|
|
156
|
-
B.textRecord("Hello, world!"),
|
|
157
|
-
B.uriRecord("https://www.google.com"),
|
|
158
|
-
B.jsonRecord(
|
|
159
|
-
JSON.stringify({
|
|
160
|
-
name: "John Doe",
|
|
161
|
-
age: 30,
|
|
162
|
-
email: "john.doe@example.com",
|
|
163
|
-
})
|
|
164
|
-
),
|
|
165
|
-
])
|
|
166
|
-
);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
return <Button title="Write NDEF" onPress={writeNdef} />;
|
|
170
|
-
}
|
|
150
|
+
const { message, tag } = await nfc.ndef.readFull();
|
|
151
|
+
console.log("Tag ID:", tag.id);
|
|
152
|
+
console.log("Records:", message.ndefMessage);
|
|
171
153
|
```
|
|
172
154
|
|
|
173
155
|
---
|
|
174
156
|
|
|
175
|
-
|
|
157
|
+
### High-Level NFC-V Operations
|
|
176
158
|
|
|
177
159
|
**Cross-platform:** Works identically on iOS and Android.
|
|
178
160
|
|
|
179
161
|
```tsx
|
|
180
162
|
import { nfc } from "@spencerls/react-native-nfc";
|
|
181
163
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
console.log("Tag ID:", tag.id);
|
|
186
|
-
console.log("Records:", message.ndefMessage);
|
|
187
|
-
};
|
|
164
|
+
// Read a single block
|
|
165
|
+
const data = await nfc.v.readBlock(0);
|
|
166
|
+
console.log("Block 0:", data);
|
|
188
167
|
|
|
189
|
-
|
|
190
|
-
|
|
168
|
+
// Write a single block
|
|
169
|
+
const writeData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
|
|
170
|
+
await nfc.v.writeBlock(0, writeData);
|
|
171
|
+
|
|
172
|
+
// Get system info
|
|
173
|
+
const info = await nfc.v.getSystemInfo();
|
|
174
|
+
console.log("Blocks:", info.numberOfBlocks);
|
|
175
|
+
console.log("Block size:", info.blockSize);
|
|
191
176
|
```
|
|
192
177
|
|
|
193
178
|
---
|
|
194
179
|
|
|
195
|
-
## Custom NFC-V Operations
|
|
180
|
+
## Advanced: Custom NFC-V Operations
|
|
196
181
|
|
|
197
182
|
**Cross-platform:** Works identically on iOS and Android.
|
|
198
183
|
|
|
199
184
|
```tsx
|
|
200
185
|
import { nfc, nfcTag, nfcVTag } from "@spencerls/react-native-nfc";
|
|
201
186
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const buffer = new Uint8Array();
|
|
209
|
-
let offset = 0;
|
|
210
|
-
|
|
211
|
-
// Read blocks 0, 2, 4, 6
|
|
212
|
-
for (let i = 0; i < 8; i += 2) {
|
|
213
|
-
const block = await nfcVTag.readBlock(tag.id, i);
|
|
214
|
-
buffer.set(block, offset);
|
|
215
|
-
offset += block.length;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return buffer;
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
console.log("Data:", data);
|
|
222
|
-
};
|
|
187
|
+
await nfc.service.startTech(
|
|
188
|
+
nfcVTag.tech,
|
|
189
|
+
async () => {
|
|
190
|
+
const tag = await nfcTag.getTag();
|
|
191
|
+
if (!tag?.id) throw new Error("No NFC-V tag detected");
|
|
223
192
|
|
|
224
|
-
|
|
225
|
-
|
|
193
|
+
const buffer = new Uint8Array();
|
|
194
|
+
let offset = 0;
|
|
195
|
+
|
|
196
|
+
// Read blocks 0, 2, 4, 6
|
|
197
|
+
for (let i = 0; i < 8; i += 2) {
|
|
198
|
+
const block = await nfcVTag.readBlock(tag.id, i);
|
|
199
|
+
buffer.set(block, offset);
|
|
200
|
+
offset += block.length;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
console.log("Data:", buffer);
|
|
204
|
+
}
|
|
205
|
+
);
|
|
226
206
|
```
|
|
227
207
|
|
|
228
208
|
---
|
|
229
209
|
|
|
230
|
-
##
|
|
210
|
+
## React Hooks Reference
|
|
231
211
|
|
|
232
|
-
|
|
212
|
+
### useNfcTech
|
|
213
|
+
|
|
214
|
+
One-shot technology session. Executes once when triggered.
|
|
233
215
|
|
|
234
216
|
```tsx
|
|
235
|
-
|
|
217
|
+
const { startTech } = useNfcTech(
|
|
218
|
+
tech: NfcTech[],
|
|
219
|
+
withTechnology: () => Promise<void>,
|
|
220
|
+
afterTechnology?: () => Promise<void>,
|
|
221
|
+
options?: RegisterTagEventOpts
|
|
222
|
+
);
|
|
223
|
+
```
|
|
236
224
|
|
|
237
|
-
|
|
238
|
-
const readBlock = async () => {
|
|
239
|
-
const data = await nfc.v.readBlock(0);
|
|
240
|
-
console.log("Block 0:", data);
|
|
241
|
-
};
|
|
225
|
+
### useNfcTechLoop
|
|
242
226
|
|
|
243
|
-
|
|
244
|
-
const data = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
|
|
245
|
-
await nfc.v.writeBlock(0, data);
|
|
246
|
-
};
|
|
227
|
+
Continuous technology session loop. Automatically restarts after each tag.
|
|
247
228
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
229
|
+
```tsx
|
|
230
|
+
const { start, stop, isRunning } = useNfcTechLoop(
|
|
231
|
+
tech: NfcTech[],
|
|
232
|
+
withTechnology: () => Promise<void>,
|
|
233
|
+
afterTechnology?: () => Promise<void>,
|
|
234
|
+
options?: RegisterTagEventOpts
|
|
235
|
+
);
|
|
236
|
+
```
|
|
252
237
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
)
|
|
260
|
-
|
|
238
|
+
### useNfcTagEvent
|
|
239
|
+
|
|
240
|
+
One-shot tag event. Executes once when a tag is detected.
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
const { startTech } = useNfcTagEvent(
|
|
244
|
+
onTag: (tag: TagEvent) => Promise<void>
|
|
245
|
+
);
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### useNfcTagEventLoop
|
|
249
|
+
|
|
250
|
+
Continuous tag event loop. Automatically restarts after each tag.
|
|
251
|
+
|
|
252
|
+
```tsx
|
|
253
|
+
const { start, stop, isRunning } = useNfcTagEventLoop(
|
|
254
|
+
onTag: (tag: TagEvent) => Promise<void>,
|
|
255
|
+
options?: RegisterTagEventOpts
|
|
256
|
+
);
|
|
261
257
|
```
|
|
262
258
|
|
|
263
259
|
---
|
|
264
260
|
|
|
265
261
|
## API Overview
|
|
266
262
|
|
|
267
|
-
**Cross-platform:** All APIs
|
|
263
|
+
**Cross-platform:** All APIs work identically on iOS and Android.
|
|
268
264
|
|
|
269
265
|
```ts
|
|
270
|
-
import {
|
|
266
|
+
import {
|
|
267
|
+
nfc,
|
|
268
|
+
nfcService,
|
|
269
|
+
nfcTag,
|
|
270
|
+
nfcVTag,
|
|
271
|
+
nfcNdefTag
|
|
272
|
+
} from "@spencerls/react-native-nfc";
|
|
271
273
|
|
|
272
274
|
// High-level namespace operations (auto-manages technology sessions)
|
|
273
275
|
await nfc.tag.getTag([NfcTech.NfcV]);
|
|
@@ -278,10 +280,11 @@ await nfc.ndef.write(records);
|
|
|
278
280
|
await nfc.ndef.readMessage();
|
|
279
281
|
await nfc.ndef.readFull();
|
|
280
282
|
|
|
281
|
-
//
|
|
282
|
-
await nfc.service.
|
|
283
|
+
// Custom operations using service
|
|
284
|
+
await nfc.service.startTech(nfcVTag.tech, async () => {
|
|
283
285
|
const tag = await nfcTag.getTag();
|
|
284
286
|
const block = await nfcVTag.readBlock(tag.id, 0);
|
|
287
|
+
console.log(block);
|
|
285
288
|
});
|
|
286
289
|
|
|
287
290
|
// NDEF Builder
|
|
@@ -294,9 +297,11 @@ const records = nfc.ndef.Builder.records((B) => [
|
|
|
294
297
|
]);
|
|
295
298
|
|
|
296
299
|
// Service control
|
|
297
|
-
|
|
298
|
-
await
|
|
299
|
-
await
|
|
300
|
+
await nfcService.startTech(tech, withTech);
|
|
301
|
+
await nfcService.startTechLoop(tech, withTech);
|
|
302
|
+
await nfcService.startTagEvent(onTag);
|
|
303
|
+
await nfcService.startTagEventLoop(onTag);
|
|
304
|
+
await nfcService.stop();
|
|
300
305
|
```
|
|
301
306
|
|
|
302
307
|
---
|
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import * as react_native_nfc_manager from 'react-native-nfc-manager';
|
|
2
|
-
import {
|
|
2
|
+
import { NfcTech, RegisterTagEventOpts, TagEvent, NdefRecord, TNF, ISOLangCode, NdefStatus } from 'react-native-nfc-manager';
|
|
3
3
|
|
|
4
|
-
declare class
|
|
5
|
-
static
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
static
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
declare class NfcService {
|
|
5
|
+
private static instance;
|
|
6
|
+
private strategies;
|
|
7
|
+
private stateMachine;
|
|
8
|
+
private jobRetry;
|
|
9
|
+
private isExecutingJobs;
|
|
10
|
+
static getInstance(): NfcService;
|
|
11
|
+
startTech(tech: NfcTech[], withTechnology: () => Promise<void>, afterTechnology?: () => Promise<void>, options?: RegisterTagEventOpts): Promise<void>;
|
|
12
|
+
startTechLoop(tech: NfcTech[], withTechnology: () => Promise<void>, afterTechnology?: () => Promise<void>, options?: RegisterTagEventOpts): Promise<void>;
|
|
13
|
+
startTagEvent(onTag: (tag: TagEvent) => Promise<void>): Promise<void>;
|
|
14
|
+
startTagEventLoop(onTag: (tag: TagEvent) => Promise<void>, options?: RegisterTagEventOpts): Promise<void>;
|
|
15
|
+
stop(): Promise<void>;
|
|
16
|
+
private executeOrQueue;
|
|
17
|
+
private executeJob;
|
|
14
18
|
}
|
|
19
|
+
declare const nfcService: NfcService;
|
|
15
20
|
|
|
16
21
|
type NdefBuilder = (r: typeof Builder) => NdefRecord[];
|
|
17
22
|
interface BuildRecordInit {
|
|
@@ -28,45 +33,17 @@ interface NdefMessageResult {
|
|
|
28
33
|
canMakeReadOnly: boolean;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
type NfcMode = "idle" | "starting" | "active" | "stopping" | "technology";
|
|
42
|
-
interface NfcState {
|
|
43
|
-
mode: NfcMode;
|
|
44
|
-
tag: TagEvent | null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type NfcListener = (state: NfcState) => void;
|
|
48
|
-
declare class NfcService {
|
|
49
|
-
private state;
|
|
50
|
-
private listeners;
|
|
51
|
-
private isProcessingTag;
|
|
52
|
-
private currentOnTag?;
|
|
53
|
-
private currentCooldownMs;
|
|
54
|
-
private cooldownTimer?;
|
|
55
|
-
private readerModeFlags_ANDROID;
|
|
56
|
-
constructor();
|
|
57
|
-
enableReaderMode_ANDROID(flags: number): void;
|
|
58
|
-
private setState;
|
|
59
|
-
getState(): NfcState;
|
|
60
|
-
subscribe(fn: NfcListener): () => void;
|
|
61
|
-
startReader(onTag?: (tag: TagEvent) => Promise<void> | void, options?: {
|
|
62
|
-
cooldownMs?: number;
|
|
63
|
-
}): Promise<void>;
|
|
64
|
-
stopReader(): Promise<void>;
|
|
65
|
-
private _resetReaderState;
|
|
66
|
-
withTechnology<T>(tech: NfcTech | NfcTech[], handler: () => Promise<T>): Promise<T>;
|
|
67
|
-
private withTechnologyReaderMode_ANDROID;
|
|
36
|
+
declare class Builder {
|
|
37
|
+
static records(b: NdefBuilder): NdefRecord[];
|
|
38
|
+
static message(b: NdefBuilder): number[];
|
|
39
|
+
static record(init: BuildRecordInit): NdefRecord;
|
|
40
|
+
static textRecord(text: string, lang?: ISOLangCode, encoding?: "utf8" | "utf16", id?: string): NdefRecord;
|
|
41
|
+
static uriRecord(uri: string, id?: string): NdefRecord;
|
|
42
|
+
static jsonRecord(payload: string | Uint8Array | number[], id?: string): NdefRecord;
|
|
43
|
+
static mimeRecord(mimeType: string, payload: string | Uint8Array | number[], id?: string): NdefRecord;
|
|
44
|
+
static externalRecord(domain: string, type: string, payload: string | Uint8Array | number[], id?: string): NdefRecord;
|
|
45
|
+
static createEmpty(): NdefRecord;
|
|
68
46
|
}
|
|
69
|
-
declare const nfcService: NfcService;
|
|
70
47
|
|
|
71
48
|
declare function readMessage$1(): Promise<NdefMessageResult>;
|
|
72
49
|
declare function write$1(records: NdefRecord[]): Promise<void>;
|
|
@@ -100,7 +77,17 @@ declare const nfcTag: {
|
|
|
100
77
|
readonly getTag: typeof getTag$1;
|
|
101
78
|
};
|
|
102
79
|
|
|
103
|
-
declare function getTag(tech: NfcTech
|
|
80
|
+
declare function getTag(tech: NfcTech[]): Promise<TagEvent>;
|
|
81
|
+
|
|
82
|
+
type SystemInfo = {
|
|
83
|
+
uid?: string;
|
|
84
|
+
dsfid?: number;
|
|
85
|
+
afi?: number;
|
|
86
|
+
numberOfBlocks?: number;
|
|
87
|
+
blockSize?: number;
|
|
88
|
+
icReference?: number;
|
|
89
|
+
manufacturer?: string;
|
|
90
|
+
};
|
|
104
91
|
|
|
105
92
|
declare function transceive(bytes: number[]): Promise<number[]>;
|
|
106
93
|
declare function readBlock$1(tagId: string, blockNumber: number): Promise<Uint8Array>;
|
|
@@ -178,7 +165,7 @@ declare namespace utils {
|
|
|
178
165
|
}
|
|
179
166
|
|
|
180
167
|
declare const nfcVTag: {
|
|
181
|
-
readonly tech: react_native_nfc_manager.NfcTech
|
|
168
|
+
readonly tech: react_native_nfc_manager.NfcTech[];
|
|
182
169
|
readonly utils: typeof utils;
|
|
183
170
|
readonly transceive: typeof transceive;
|
|
184
171
|
readonly readBlock: typeof readBlock$1;
|
|
@@ -227,20 +214,24 @@ declare const nfc: {
|
|
|
227
214
|
};
|
|
228
215
|
};
|
|
229
216
|
|
|
230
|
-
declare function
|
|
231
|
-
|
|
232
|
-
}
|
|
217
|
+
declare function useNfcTech(tech: NfcTech[], withTechnology: () => Promise<void>, afterTechnology?: () => Promise<void>, options?: RegisterTagEventOpts): {
|
|
218
|
+
startTech: () => void;
|
|
219
|
+
};
|
|
233
220
|
|
|
234
|
-
declare function
|
|
235
|
-
start: (
|
|
236
|
-
stop: () => void
|
|
221
|
+
declare function useNfcTechLoop(tech: NfcTech[], withTechnology: () => Promise<void>, afterTechnology?: () => Promise<void>, options?: RegisterTagEventOpts): {
|
|
222
|
+
start: () => Promise<void>;
|
|
223
|
+
stop: () => Promise<void>;
|
|
224
|
+
isRunning: boolean;
|
|
237
225
|
};
|
|
238
226
|
|
|
239
|
-
declare function
|
|
227
|
+
declare function useNfcTagEvent(onTag: (tag: TagEvent) => Promise<void>): {
|
|
228
|
+
startTech: () => void;
|
|
229
|
+
};
|
|
240
230
|
|
|
241
|
-
declare function
|
|
242
|
-
|
|
243
|
-
|
|
231
|
+
declare function useNfcTagEventLoop(onTag: (tag: TagEvent) => Promise<void>, options?: RegisterTagEventOpts): {
|
|
232
|
+
start: () => Promise<void>;
|
|
233
|
+
stop: () => Promise<void>;
|
|
234
|
+
isRunning: boolean;
|
|
244
235
|
};
|
|
245
236
|
|
|
246
|
-
export { type BuildRecordInit, type NdefBuilder, type NdefMessageResult, type
|
|
237
|
+
export { type BuildRecordInit, type NdefBuilder, type NdefMessageResult, type SystemInfo, nfc, nfcNdefTag, nfcService, nfcTag, nfcVTag, useNfcTagEvent, useNfcTagEventLoop, useNfcTech, useNfcTechLoop };
|