react-native-nfc-manager 4.0.0-beta.0 → 4.0.0-beta.10
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 +146 -49
- package/android/src/main/java/community/revteltech/nfc/MifareClassicHandler.java +419 -0
- package/android/src/main/java/community/revteltech/nfc/MifareUltralightHandler.java +84 -0
- package/android/src/main/java/community/revteltech/nfc/NdefHandler.java +373 -0
- package/android/src/main/java/community/revteltech/nfc/NfcAdapterStateChangedReceiver.java +48 -0
- package/android/src/main/java/community/revteltech/nfc/NfcErrorCodes.java +16 -0
- package/android/src/main/java/community/revteltech/nfc/NfcManager.java +348 -1087
- package/android/src/main/java/community/revteltech/nfc/NfcManagerIOSStubBase.java +130 -0
- package/android/src/main/java/community/revteltech/nfc/NfcTechIoRouter.java +258 -0
- package/android/src/main/java/community/revteltech/nfc/TagTechnologyRequest.java +19 -7
- package/android/src/main/java/community/revteltech/nfc/Util.java +275 -2
- package/app.plugin.js +8 -9
- package/dist/ndef-lib/constants.js +67 -0
- package/dist/ndef-lib/constants.js.map +1 -0
- package/dist/ndef-lib/index.js +79 -0
- package/dist/ndef-lib/index.js.map +1 -0
- package/dist/ndef-lib/ndef-text.js +29 -0
- package/dist/ndef-lib/ndef-text.js.map +1 -0
- package/dist/ndef-lib/ndef-uri.js +40 -0
- package/dist/ndef-lib/ndef-uri.js.map +1 -0
- package/dist/ndef-lib/ndef-wifi-simple.js +100 -0
- package/dist/ndef-lib/ndef-wifi-simple.js.map +1 -0
- package/dist/ndef-lib/ndef.js +152 -0
- package/dist/ndef-lib/ndef.js.map +1 -0
- package/dist/ndef-lib/stringifier.js +155 -0
- package/dist/ndef-lib/stringifier.js.map +1 -0
- package/dist/ndef-lib/util.js +126 -0
- package/dist/ndef-lib/util.js.map +1 -0
- package/dist/specs/NativeNfcManager.js +5 -0
- package/dist/specs/NativeNfcManager.js.map +1 -0
- package/dist/src/NativeNfcManager.js +55 -0
- package/dist/src/NativeNfcManager.js.map +1 -0
- package/dist/src/NfcError.js +220 -0
- package/dist/src/NfcError.js.map +1 -0
- package/dist/src/NfcManager.js +175 -0
- package/dist/src/NfcManager.js.map +1 -0
- package/dist/src/NfcManagerAndroid.js +112 -0
- package/dist/src/NfcManagerAndroid.js.map +1 -0
- package/dist/src/NfcManagerIOS.js +119 -0
- package/dist/src/NfcManagerIOS.js.map +1 -0
- package/dist/src/NfcTech/Iso15693HandlerIOS.js +99 -0
- package/dist/src/NfcTech/Iso15693HandlerIOS.js.map +1 -0
- package/dist/src/NfcTech/IsoDepHandler.js +29 -0
- package/dist/src/NfcTech/IsoDepHandler.js.map +1 -0
- package/dist/src/NfcTech/MifareClassicHandlerAndroid.js +68 -0
- package/dist/src/NfcTech/MifareClassicHandlerAndroid.js.map +1 -0
- package/dist/src/NfcTech/MifareUltralightHandlerAndroid.js +23 -0
- package/dist/src/NfcTech/MifareUltralightHandlerAndroid.js.map +1 -0
- package/dist/src/NfcTech/NdefFormatableHandlerAndroid.js +16 -0
- package/dist/src/NfcTech/NdefFormatableHandlerAndroid.js.map +1 -0
- package/dist/src/NfcTech/NdefHandler.js +54 -0
- package/dist/src/NfcTech/NdefHandler.js.map +1 -0
- package/dist/src/NfcTech/NfcAHandler.js +16 -0
- package/dist/src/NfcTech/NfcAHandler.js.map +1 -0
- package/dist/src/NfcTech/NfcVHandler.js +33 -0
- package/dist/src/NfcTech/NfcVHandler.js.map +1 -0
- package/dist/src/index.js +53 -0
- package/dist/src/index.js.map +1 -0
- package/index.d.ts +110 -46
- package/ios/NfcManager.h +2 -11
- package/ios/NfcManager.mm +264 -438
- package/ios/RNNfcBridgeUtil.h +28 -0
- package/ios/RNNfcBridgeUtil.mm +52 -0
- package/ios/RNNfcManager+Felica.swift +61 -0
- package/ios/RNNfcManager+Iso15693.swift +895 -0
- package/ios/RNNfcManager+IsoDep.swift +145 -0
- package/ios/RNNfcManager+Mifare.swift +61 -0
- package/ios/RNNfcManager+Ndef.swift +120 -0
- package/ios/RNNfcManager.h +251 -0
- package/ios/RNNfcManager.swift +648 -0
- package/ios/RNNfcSessionDelegateProxy.swift +104 -0
- package/ios/RNNfcSwiftUtil.swift +34 -0
- package/ndef-lib/{constants.js → constants.ts} +2 -0
- package/ndef-lib/{index.js → index.ts} +23 -12
- package/ndef-lib/{ndef-text.js → ndef-text.ts} +7 -2
- package/ndef-lib/{ndef-uri.js → ndef-uri.ts} +8 -3
- package/ndef-lib/{ndef-wifi-simple.js → ndef-wifi-simple.ts} +34 -11
- package/ndef-lib/{ndef.js → ndef.ts} +53 -25
- package/ndef-lib/{stringifier.js → stringifier.ts} +27 -10
- package/ndef-lib/{util.js → util.ts} +13 -8
- package/package.json +44 -13
- package/react-native-nfc-manager.podspec +3 -2
- package/specs/NativeNfcManager.ts +95 -0
- package/src/NativeNfcManager.ts +84 -0
- package/src/{NfcError.js → NfcError.ts} +6 -17
- package/src/{NfcManager.js → NfcManager.ts} +51 -34
- package/src/{NfcManagerAndroid.js → NfcManagerAndroid.ts} +27 -8
- package/src/{NfcManagerIOS.js → NfcManagerIOS.ts} +31 -10
- package/src/NfcTech/{Iso15693HandlerIOS.js → Iso15693HandlerIOS.ts} +64 -36
- package/src/NfcTech/{IsoDepHandler.js → IsoDepHandler.ts} +8 -5
- package/src/NfcTech/{MifareClassicHandlerAndroid.js → MifareClassicHandlerAndroid.ts} +33 -24
- package/src/NfcTech/{MifareUltralightHandlerAndroid.js → MifareUltralightHandlerAndroid.ts} +14 -5
- package/src/NfcTech/{NdefFormatableHandlerAndroid.js → NdefFormatableHandlerAndroid.ts} +9 -2
- package/src/NfcTech/{NdefHandler.js → NdefHandler.ts} +19 -6
- package/src/NfcTech/{NfcAHandler.js → NfcAHandler.ts} +6 -3
- package/src/NfcTech/{NfcVHandler.js → NfcVHandler.ts} +8 -5
- package/src/__mocks__/{NativeNfcManager.js → NativeNfcManager.ts} +4 -1
- package/src/{index.js → index.ts} +1 -1
- package/android/src/main/java/community/revteltech/nfc/JsonConvert.java +0 -141
- package/android/src/main/java/community/revteltech/nfc/MifareUtil.java +0 -84
- package/ios/NfcManager+Felica.mm +0 -43
- package/ios/NfcManager+Iso15693.mm +0 -600
- package/ios/NfcManager+IsoDep.mm +0 -83
- package/ios/NfcManager+Mifare.mm +0 -43
- package/ios/Util.mm +0 -55
- package/src/NativeNfcManager.js +0 -37
|
@@ -1,600 +0,0 @@
|
|
|
1
|
-
#import "NfcManager.h"
|
|
2
|
-
#import "React/RCTBridge.h"
|
|
3
|
-
#import "React/RCTConvert.h"
|
|
4
|
-
#import "React/RCTEventDispatcher.h"
|
|
5
|
-
#import "React/RCTLog.h"
|
|
6
|
-
|
|
7
|
-
@interface NfcManager (Iso15693)
|
|
8
|
-
@end
|
|
9
|
-
|
|
10
|
-
@implementation NfcManager (Iso15693)
|
|
11
|
-
|
|
12
|
-
RCT_EXPORT_METHOD(iso15693_getSystemInfo:(nonnull NSNumber *)flags callback:(nonnull RCTResponseSenderBlock)callback)
|
|
13
|
-
{
|
|
14
|
-
if (@available(iOS 14.0, *)) {
|
|
15
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
16
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
21
|
-
if (!tag) {
|
|
22
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
RequestFlag rFlag = [flags unsignedIntValue];
|
|
27
|
-
|
|
28
|
-
[tag getSystemInfoWithRequestFlag:rFlag completionHandler:
|
|
29
|
-
^(NSInteger dsfid, NSInteger afi, NSInteger blockSize, NSInteger blockCount, NSInteger icReference, NSError *error) {
|
|
30
|
-
if (error) {
|
|
31
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
callback(@[[NSNull null], @{
|
|
36
|
-
@"dsfid": @(dsfid),
|
|
37
|
-
@"afi": @(afi),
|
|
38
|
-
@"blockSize": @(blockSize),
|
|
39
|
-
@"blockCount": @(blockCount),
|
|
40
|
-
@"icReference": @(icReference)
|
|
41
|
-
}]);
|
|
42
|
-
}];
|
|
43
|
-
} else {
|
|
44
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
RCT_EXPORT_METHOD(iso15693_readSingleBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
49
|
-
{
|
|
50
|
-
if (@available(iOS 14.0, *)) {
|
|
51
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
52
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
57
|
-
if (!tag) {
|
|
58
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
63
|
-
uint8_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
|
|
64
|
-
|
|
65
|
-
[tag readSingleBlockWithRequestFlags:flags
|
|
66
|
-
blockNumber:blockNumber
|
|
67
|
-
completionHandler:^(NSData *resp, NSError *error) {
|
|
68
|
-
if (error) {
|
|
69
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
callback(@[[NSNull null], dataToArray(resp)]);
|
|
74
|
-
}];
|
|
75
|
-
} else {
|
|
76
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
RCT_EXPORT_METHOD(iso15693_readMultipleBlocks:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
81
|
-
{
|
|
82
|
-
if (@available(iOS 14.0, *)) {
|
|
83
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
84
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
89
|
-
if (!tag) {
|
|
90
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
95
|
-
NSRange blockRange = NSMakeRange(
|
|
96
|
-
[[options objectForKey:@"blockNumber"] unsignedIntValue],
|
|
97
|
-
[[options objectForKey:@"blockCount"] unsignedIntValue]
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
[tag readMultipleBlocksWithRequestFlags:flags
|
|
101
|
-
blockRange:blockRange
|
|
102
|
-
completionHandler:^(NSArray<NSData *> *dataBlocks, NSError *error) {
|
|
103
|
-
if (error) {
|
|
104
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
NSMutableArray *blocks = [NSMutableArray arrayWithCapacity:[dataBlocks count]];
|
|
108
|
-
[dataBlocks enumerateObjectsUsingBlock:^(NSData *blockData, NSUInteger idx, BOOL *stop) {
|
|
109
|
-
[blocks addObject:dataToArray(blockData)];
|
|
110
|
-
}];
|
|
111
|
-
callback(@[[NSNull null], blocks]);
|
|
112
|
-
}];
|
|
113
|
-
} else {
|
|
114
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
RCT_EXPORT_METHOD(iso15693_writeSingleBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
119
|
-
{
|
|
120
|
-
if (@available(iOS 14.0, *)) {
|
|
121
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
122
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
127
|
-
if (!tag) {
|
|
128
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
133
|
-
uint8_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
|
|
134
|
-
NSData *dataBlock = arrayToData([options mutableArrayValueForKey:@"dataBlock"]);
|
|
135
|
-
|
|
136
|
-
[tag writeSingleBlockWithRequestFlags:flags
|
|
137
|
-
blockNumber:blockNumber
|
|
138
|
-
dataBlock:dataBlock
|
|
139
|
-
completionHandler:^(NSError *error) {
|
|
140
|
-
if (error) {
|
|
141
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
callback(@[]);
|
|
146
|
-
}];
|
|
147
|
-
} else {
|
|
148
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
RCT_EXPORT_METHOD(iso15693_lockBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
153
|
-
{
|
|
154
|
-
if (@available(iOS 14.0, *)) {
|
|
155
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
156
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
161
|
-
if (!tag) {
|
|
162
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
167
|
-
uint8_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
|
|
168
|
-
|
|
169
|
-
[tag lockBlockWithRequestFlags:flags
|
|
170
|
-
blockNumber:blockNumber
|
|
171
|
-
completionHandler:^(NSError *error) {
|
|
172
|
-
if (error) {
|
|
173
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
callback(@[]);
|
|
178
|
-
}];
|
|
179
|
-
} else {
|
|
180
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
RCT_EXPORT_METHOD(iso15693_writeAFI:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
185
|
-
{
|
|
186
|
-
if (@available(iOS 14.0, *)) {
|
|
187
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
188
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
193
|
-
if (!tag) {
|
|
194
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
199
|
-
uint8_t afi = [[options objectForKey:@"afi"] unsignedIntValue];
|
|
200
|
-
|
|
201
|
-
[tag writeAFIWithRequestFlag:flags
|
|
202
|
-
afi:afi
|
|
203
|
-
completionHandler:^(NSError *error) {
|
|
204
|
-
if (error) {
|
|
205
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
callback(@[]);
|
|
210
|
-
}];
|
|
211
|
-
} else {
|
|
212
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
RCT_EXPORT_METHOD(iso15693_lockAFI:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
217
|
-
{
|
|
218
|
-
if (@available(iOS 14.0, *)) {
|
|
219
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
220
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
225
|
-
if (!tag) {
|
|
226
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
231
|
-
|
|
232
|
-
[tag lockAFIWithRequestFlag:flags
|
|
233
|
-
completionHandler:^(NSError *error) {
|
|
234
|
-
if (error) {
|
|
235
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
callback(@[]);
|
|
240
|
-
}];
|
|
241
|
-
} else {
|
|
242
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
RCT_EXPORT_METHOD(iso15693_writeDSFID:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
247
|
-
{
|
|
248
|
-
if (@available(iOS 14.0, *)) {
|
|
249
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
250
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
255
|
-
if (!tag) {
|
|
256
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
261
|
-
uint8_t dsfid = [[options objectForKey:@"dsfid"] unsignedIntValue];
|
|
262
|
-
|
|
263
|
-
[tag writeDSFIDWithRequestFlag:flags
|
|
264
|
-
dsfid:dsfid
|
|
265
|
-
completionHandler:^(NSError *error) {
|
|
266
|
-
if (error) {
|
|
267
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
callback(@[]);
|
|
272
|
-
}];
|
|
273
|
-
} else {
|
|
274
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
RCT_EXPORT_METHOD(iso15693_lockDSFID:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
279
|
-
{
|
|
280
|
-
if (@available(iOS 14.0, *)) {
|
|
281
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
282
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
287
|
-
if (!tag) {
|
|
288
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
293
|
-
|
|
294
|
-
// notice thie method name, DSFID -> DFSID, seems to be a typo in Core NFC
|
|
295
|
-
[tag lockDFSIDWithRequestFlag:flags
|
|
296
|
-
completionHandler:^(NSError *error) {
|
|
297
|
-
if (error) {
|
|
298
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
callback(@[]);
|
|
303
|
-
}];
|
|
304
|
-
} else {
|
|
305
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
RCT_EXPORT_METHOD(iso15693_resetToReady:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
310
|
-
{
|
|
311
|
-
if (@available(iOS 14.0, *)) {
|
|
312
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
313
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
318
|
-
if (!tag) {
|
|
319
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
324
|
-
|
|
325
|
-
[tag resetToReadyWithRequestFlags:flags
|
|
326
|
-
completionHandler:^(NSError *error) {
|
|
327
|
-
if (error) {
|
|
328
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
callback(@[]);
|
|
333
|
-
}];
|
|
334
|
-
} else {
|
|
335
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
RCT_EXPORT_METHOD(iso15693_select:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
340
|
-
{
|
|
341
|
-
if (@available(iOS 14.0, *)) {
|
|
342
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
343
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
348
|
-
if (!tag) {
|
|
349
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
354
|
-
|
|
355
|
-
[tag selectWithRequestFlags:flags
|
|
356
|
-
completionHandler:^(NSError *error) {
|
|
357
|
-
if (error) {
|
|
358
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
callback(@[]);
|
|
363
|
-
}];
|
|
364
|
-
} else {
|
|
365
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
RCT_EXPORT_METHOD(iso15693_stayQuiet:(nonnull RCTResponseSenderBlock)callback)
|
|
370
|
-
{
|
|
371
|
-
if (@available(iOS 14.0, *)) {
|
|
372
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
373
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
378
|
-
if (!tag) {
|
|
379
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
[tag stayQuietWithCompletionHandler:^(NSError *error) {
|
|
384
|
-
if (error) {
|
|
385
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
callback(@[]);
|
|
390
|
-
}];
|
|
391
|
-
} else {
|
|
392
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
RCT_EXPORT_METHOD(iso15693_customCommand:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
398
|
-
{
|
|
399
|
-
if (@available(iOS 14.0, *)) {
|
|
400
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
401
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
406
|
-
if (!tag) {
|
|
407
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
412
|
-
NSInteger customCommandCode = [[options objectForKey:@"customCommandCode"] integerValue];
|
|
413
|
-
NSData *customRequestParameters = arrayToData([options mutableArrayValueForKey:@"customRequestParameters"]);
|
|
414
|
-
|
|
415
|
-
[tag customCommandWithRequestFlag:flags
|
|
416
|
-
customCommandCode: customCommandCode
|
|
417
|
-
customRequestParameters: customRequestParameters
|
|
418
|
-
completionHandler:^(NSData *resp, NSError *error) {
|
|
419
|
-
if (error) {
|
|
420
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
callback(@[[NSNull null], dataToArray(resp)]);
|
|
425
|
-
}];
|
|
426
|
-
} else {
|
|
427
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
RCT_EXPORT_METHOD(iso15693_sendRequest:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
432
|
-
{
|
|
433
|
-
if (@available(iOS 14.0, *)) {
|
|
434
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
435
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
440
|
-
if (!tag) {
|
|
441
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
NSInteger flags = [[options objectForKey:@"flags"] integerValue];
|
|
446
|
-
NSInteger commandCode = [[options objectForKey:@"commandCode"] integerValue];
|
|
447
|
-
NSData *data = arrayToData([options mutableArrayValueForKey:@"data"]);
|
|
448
|
-
|
|
449
|
-
[tag sendRequestWithFlag:flags
|
|
450
|
-
commandCode:commandCode
|
|
451
|
-
data:data
|
|
452
|
-
completionHandler:^(NFCISO15693ResponseFlag responseFlag, NSData *resp, NSError *error) {
|
|
453
|
-
if (error) {
|
|
454
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
callback(@[[NSNull null], [NSNumber numberWithLong:responseFlag], dataToArray(resp)]);
|
|
458
|
-
}];
|
|
459
|
-
} else {
|
|
460
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
RCT_EXPORT_METHOD(iso15693_extendedReadSingleBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
465
|
-
{
|
|
466
|
-
if (@available(iOS 14.0, *)) {
|
|
467
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
468
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
473
|
-
if (!tag) {
|
|
474
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
479
|
-
uint16_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
|
|
480
|
-
|
|
481
|
-
[tag extendedReadSingleBlockWithRequestFlags:flags
|
|
482
|
-
blockNumber:blockNumber
|
|
483
|
-
completionHandler:^(NSData *resp, NSError *error) {
|
|
484
|
-
if (error) {
|
|
485
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
callback(@[[NSNull null], dataToArray(resp)]);
|
|
490
|
-
}];
|
|
491
|
-
} else {
|
|
492
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
RCT_EXPORT_METHOD(iso15693_extendedReadMultipleBlocks:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
497
|
-
{
|
|
498
|
-
if (@available(iOS 14.0, *)) {
|
|
499
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
500
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
505
|
-
if (!tag) {
|
|
506
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
507
|
-
return;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
511
|
-
NSRange blockRange = NSMakeRange(
|
|
512
|
-
[[options objectForKey:@"blockNumber"] unsignedIntValue],
|
|
513
|
-
[[options objectForKey:@"blockCount"] unsignedIntValue]
|
|
514
|
-
);
|
|
515
|
-
|
|
516
|
-
[tag extendedReadMultipleBlocksWithRequestFlags:flags
|
|
517
|
-
blockRange:blockRange
|
|
518
|
-
completionHandler:^(NSArray<NSData *> *dataBlocks, NSError *error) {
|
|
519
|
-
if (error) {
|
|
520
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
NSMutableArray *blocks = [NSMutableArray arrayWithCapacity:[dataBlocks count]];
|
|
524
|
-
[dataBlocks enumerateObjectsUsingBlock:^(NSData *blockData, NSUInteger idx, BOOL *stop) {
|
|
525
|
-
[blocks addObject:dataToArray(blockData)];
|
|
526
|
-
}];
|
|
527
|
-
callback(@[[NSNull null], blocks]);
|
|
528
|
-
}];
|
|
529
|
-
} else {
|
|
530
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
RCT_EXPORT_METHOD(iso15693_extendedWriteSingleBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
535
|
-
{
|
|
536
|
-
if (@available(iOS 14.0, *)) {
|
|
537
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
538
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
543
|
-
if (!tag) {
|
|
544
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
549
|
-
uint16_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
|
|
550
|
-
NSData *dataBlock = arrayToData([options mutableArrayValueForKey:@"dataBlock"]);
|
|
551
|
-
|
|
552
|
-
[tag extendedWriteSingleBlockWithRequestFlags:flags
|
|
553
|
-
blockNumber:blockNumber
|
|
554
|
-
dataBlock: dataBlock
|
|
555
|
-
completionHandler:^(NSError *error) {
|
|
556
|
-
if (error) {
|
|
557
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
callback(@[]);
|
|
562
|
-
}];
|
|
563
|
-
} else {
|
|
564
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
RCT_EXPORT_METHOD(iso15693_extendedLockBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
|
|
569
|
-
{
|
|
570
|
-
if (@available(iOS 14.0, *)) {
|
|
571
|
-
if (![self tagSession] || ![self tagSession].connectedTag) {
|
|
572
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
id<NFCISO15693Tag> tag = [[self tagSession].connectedTag asNFCISO15693Tag];
|
|
577
|
-
if (!tag) {
|
|
578
|
-
callback(@[@"incorrect tag type", [NSNull null]]);
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
|
|
583
|
-
uint16_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
|
|
584
|
-
|
|
585
|
-
[tag extendedLockBlockWithRequestFlags:flags
|
|
586
|
-
blockNumber:blockNumber
|
|
587
|
-
completionHandler:^(NSError *error) {
|
|
588
|
-
if (error) {
|
|
589
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
callback(@[]);
|
|
594
|
-
}];
|
|
595
|
-
} else {
|
|
596
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
@end
|
package/ios/NfcManager+IsoDep.mm
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
#import "NfcManager.h"
|
|
2
|
-
#import "React/RCTBridge.h"
|
|
3
|
-
#import "React/RCTConvert.h"
|
|
4
|
-
#import "React/RCTEventDispatcher.h"
|
|
5
|
-
#import "React/RCTLog.h"
|
|
6
|
-
|
|
7
|
-
@interface NfcManager (IsoDep)
|
|
8
|
-
@end
|
|
9
|
-
|
|
10
|
-
@implementation NfcManager (IsoDep)
|
|
11
|
-
|
|
12
|
-
- (void)sendCommandAPDUBytes:(NSArray *)bytes callback: (nonnull RCTResponseSenderBlock)callback
|
|
13
|
-
{
|
|
14
|
-
if (@available(iOS 13.0, *)) {
|
|
15
|
-
if ([self tagSession] != nil) {
|
|
16
|
-
if ([self tagSession].connectedTag) {
|
|
17
|
-
id<NFCISO7816Tag> iso7816Tag = [[self tagSession].connectedTag asNFCISO7816Tag];
|
|
18
|
-
NSData *data = arrayToData(bytes);
|
|
19
|
-
NFCISO7816APDU *apdu = [[NFCISO7816APDU alloc] initWithData:data];
|
|
20
|
-
if (iso7816Tag) {
|
|
21
|
-
[iso7816Tag sendCommandAPDU:apdu completionHandler:^(NSData* response, uint8_t sw1, uint8_t sw2, NSError* error) {
|
|
22
|
-
if (error) {
|
|
23
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
24
|
-
} else {
|
|
25
|
-
callback(@[[NSNull null], dataToArray(response), [NSNumber numberWithInt:sw1], [NSNumber numberWithInt:sw2]]);
|
|
26
|
-
}
|
|
27
|
-
}];
|
|
28
|
-
return;
|
|
29
|
-
} else {
|
|
30
|
-
callback(@[@"not an iso7816 tag", [NSNull null]]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
34
|
-
} else {
|
|
35
|
-
callback(@[@"Not even registered", [NSNull null]]);
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
- (void)sendCommandAPDU:(NSDictionary *)apduData callback: (nonnull RCTResponseSenderBlock)callback
|
|
43
|
-
{
|
|
44
|
-
if (@available(iOS 13.0, *)) {
|
|
45
|
-
if ([self tagSession] != nil) {
|
|
46
|
-
if ([self tagSession].connectedTag) {
|
|
47
|
-
id<NFCISO7816Tag> iso7816Tag = [[self tagSession].connectedTag asNFCISO7816Tag];
|
|
48
|
-
NSNumber *cla = [apduData objectForKey:@"cla"];
|
|
49
|
-
NSNumber *ins = [apduData objectForKey:@"ins"];
|
|
50
|
-
NSNumber *p1 = [apduData objectForKey:@"p1"];
|
|
51
|
-
NSNumber *p2 = [apduData objectForKey:@"p2"];
|
|
52
|
-
NSArray *dataArray = [apduData objectForKey:@"data"];
|
|
53
|
-
NSData *data = arrayToData(dataArray);
|
|
54
|
-
NSNumber *le = [apduData objectForKey:@"le"];
|
|
55
|
-
|
|
56
|
-
/*
|
|
57
|
-
NFCISO7816APDU *apdu = [[NFCISO7816APDU alloc] initWithInstructionClass:0 instructionCode:0x84 p1Parameter:0 p2Parameter:0 data:[[NSData alloc] init] expectedResponseLength:8]
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
NFCISO7816APDU *apdu = [[NFCISO7816APDU alloc] initWithInstructionClass:[cla unsignedCharValue] instructionCode:[ins unsignedCharValue] p1Parameter:[p1 unsignedCharValue] p2Parameter:[p2 unsignedCharValue] data:data expectedResponseLength:[le integerValue]];
|
|
61
|
-
if (iso7816Tag) {
|
|
62
|
-
[iso7816Tag sendCommandAPDU:apdu completionHandler:^(NSData* response, uint8_t sw1, uint8_t sw2, NSError* error) {
|
|
63
|
-
if (error) {
|
|
64
|
-
callback(@[getErrorMessage(error), [NSNull null]]);
|
|
65
|
-
} else {
|
|
66
|
-
callback(@[[NSNull null], dataToArray(response), [NSNumber numberWithInt:sw1], [NSNumber numberWithInt:sw2]]);
|
|
67
|
-
}
|
|
68
|
-
}];
|
|
69
|
-
return;
|
|
70
|
-
} else {
|
|
71
|
-
callback(@[@"not an iso7816 tag", [NSNull null]]);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
callback(@[@"Not connected", [NSNull null]]);
|
|
75
|
-
} else {
|
|
76
|
-
callback(@[@"Not even registered", [NSNull null]]);
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
callback(@[@"Not support in this device", [NSNull null]]);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@end
|