react-native-nfc-manager 4.0.0-beta.9 → 4.0.0
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 +72 -281
- package/android/src/main/java/community/revteltech/nfc/NdefHandler.java +26 -2
- package/android/src/main/java/community/revteltech/nfc/Util.java +74 -2
- package/app.plugin.js +8 -9
- package/dist/ndef-lib/ndef.js +4 -5
- package/dist/ndef-lib/ndef.js.map +1 -1
- package/dist/ndef-lib/util.js +9 -1
- package/dist/ndef-lib/util.js.map +1 -1
- package/dist/src/NativeNfcManager.js +8 -1
- package/dist/src/NativeNfcManager.js.map +1 -1
- package/dist/src/runtimeCompatibility.js +39 -0
- package/dist/src/runtimeCompatibility.js.map +1 -0
- package/index.d.ts +33 -3
- package/ios/NfcManager.mm +90 -2
- package/ndef-lib/ndef.ts +5 -6
- package/ndef-lib/util.ts +10 -1
- package/package.json +20 -16
- package/src/NativeNfcManager.ts +13 -2
- package/src/runtimeCompatibility.ts +46 -0
package/README.md
CHANGED
|
@@ -2,329 +2,120 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/react-native-nfc-manager)
|
|
4
4
|
[](https://github.com/revtel/react-native-nfc-manager/actions/workflows/ci.yml)
|
|
5
|
-
[](https://github.com/whitedogg13/react-native-nfc-manager/issues)
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
NFC for React Native, built for the **New Architecture** and **Expo Development Builds**.
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Made with ❤️ by [whitedogg13](https://github.com/whitedogg13) and [revteltech](https://github.com/revtel)
|
|
12
|
-
|
|
13
|
-
> Special thanks to [javix64](https://github.com/javix64) for restructuring the documentation!
|
|
14
|
-
|
|
15
|
-
## Version Notes
|
|
16
|
-
|
|
17
|
-
- `v3` only supports legacy architecture (`v3.x.y`).
|
|
18
|
-
- `v4` targets the New Architecture and remains beta (`v4.0.0-beta.x`). Its support floor is React Native 0.76 with the New Architecture enabled; React Native 0.82 and newer are New Architecture only.
|
|
19
|
-
|
|
20
|
-
## Support Policy
|
|
21
|
-
|
|
22
|
-
- See [Support Policy](./docs/SUPPORT_POLICY.md) for official React Native version window, architecture targets, and verification matrix.
|
|
23
|
-
|
|
24
|
-
## Table of Contents
|
|
25
|
-
|
|
26
|
-
1. [Installation](#installation)
|
|
27
|
-
2. [Getting Started](#gettingstarted)
|
|
28
|
-
3. [Setup](#setup)
|
|
29
|
-
4. [Documentation](#docs)
|
|
30
|
-
5. [Nfc compatibility](#nfccompatibility)
|
|
31
|
-
6. [Usage Concept](#usageconcept)
|
|
32
|
-
7. [API](#api)
|
|
33
|
-
8. [App demo](#appdemo)
|
|
34
|
-
9. [Learn](#learn)
|
|
35
|
-
10. [Development Example](#development-example)
|
|
8
|
+
Requires **React Native 0.76+ with the New Architecture**. Use an NFC-capable physical device to test scans.
|
|
36
9
|
|
|
37
10
|
## Installation
|
|
38
11
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```shell
|
|
42
|
-
npm i --save react-native-nfc-manager
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
To evaluate the v4 beta, install an explicit `4.0.0-beta.x` version rather than relying on the default npm tag.
|
|
46
|
-
|
|
47
|
-
### iOS
|
|
48
|
-
|
|
49
|
-
This library use native-modules, so you will need to do `pod install` for iOS:
|
|
50
|
-
|
|
51
|
-
```shell
|
|
52
|
-
cd ios && pod install && cd ..
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Minimum Swift language version for iOS native sources is **Swift 5.7**.
|
|
56
|
-
|
|
57
|
-
### Android
|
|
58
|
-
|
|
59
|
-
It should be properly auto-linked, so you don't need to do anything.
|
|
60
|
-
|
|
61
|
-
## Setup
|
|
62
|
-
|
|
63
|
-
<a name="setup"></a>
|
|
64
|
-
|
|
65
|
-
### iOS
|
|
66
|
-
|
|
67
|
-
1. In [apple developer site](https://developer.apple.com/), enable capability for NFC
|
|
68
|
-
|
|
69
|
-

|
|
70
|
-
|
|
71
|
-
2. in Xcode, add `NFCReaderUsageDescription` into your `info.plist`, for example:
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
<key>NFCReaderUsageDescription</key>
|
|
75
|
-
<string>We need to use NFC</string>
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
More info on Apple's [doc](https://developer.apple.com/documentation/bundleresources/information_property_list/nfcreaderusagedescription?language=objc)
|
|
79
|
-
|
|
80
|
-
Additionally, if writing ISO7816 tags add application identifiers (aid) into your `info.plist` as needed like this.
|
|
12
|
+
```sh
|
|
13
|
+
npm install react-native-nfc-manager@beta
|
|
81
14
|
```
|
|
82
|
-
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
|
|
83
|
-
<array>
|
|
84
|
-
<string>D2760000850100</string>
|
|
85
|
-
<string>D2760000850101</string>
|
|
86
|
-
</array>
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
More info on Apple's [doc](https://developer.apple.com/documentation/corenfc/nfciso7816tag)
|
|
90
|
-
|
|
91
|
-
**Note:** If you are using `NfcTech.FelicaIOS`, you must also add the following code to your `Info.plist` file, otherwise the library will crash:
|
|
92
|
-
|
|
93
|
-
```xml
|
|
94
|
-
<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>
|
|
95
|
-
<array>
|
|
96
|
-
<string>8005</string>
|
|
97
|
-
<string>8008</string>
|
|
98
|
-
<string>0003</string>
|
|
99
|
-
<string>fe00</string>
|
|
100
|
-
<string>90b7</string>
|
|
101
|
-
<string>927a</string>
|
|
102
|
-
<string>12FC</string>
|
|
103
|
-
<string>86a7</string>
|
|
104
|
-
</array>
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
An incomplete list of aid's can be found here. [Application identifier](https://www.eftlab.com/knowledge-base/complete-list-of-application-identifiers-aid)
|
|
108
|
-
|
|
109
|
-
3. in Xcode's `Signing & Capabilities` tab, make sure `Near Field Communication Tag Reading` capability had been added, like this:
|
|
110
|
-
|
|
111
|
-

|
|
112
15
|
|
|
113
|
-
|
|
16
|
+
v4 is currently beta. Pin the resolved version for reproducible installs. See [migration](docs/MIGRATING_V3_TO_V4.md) when upgrading an existing app.
|
|
114
17
|
|
|
115
|
-
|
|
18
|
+
<a id="setup"></a>
|
|
116
19
|
|
|
117
|
-
|
|
20
|
+
### Expo Development Builds
|
|
118
21
|
|
|
119
|
-
|
|
22
|
+
Expo Go cannot load this native module. Add the config plugin to `app.json`:
|
|
120
23
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
```xml
|
|
128
|
-
<uses-permission android:name="android.permission.NFC" />
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"expo": {
|
|
27
|
+
"plugins": ["react-native-nfc-manager"]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
129
30
|
```
|
|
130
31
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
We start to support Android 12 from `v3.11.1`, and you will need to update `compileSdkVersion` to `31`, otherwise the build will fail:
|
|
32
|
+
Install the development client and build the native app:
|
|
134
33
|
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
...
|
|
143
|
-
}
|
|
34
|
+
```sh
|
|
35
|
+
npx expo install expo-dev-client
|
|
36
|
+
npx expo prebuild
|
|
37
|
+
npx expo run:ios --device
|
|
38
|
+
# Or: npx expo run:android --device
|
|
39
|
+
npx expo start --dev-client
|
|
144
40
|
```
|
|
145
41
|
|
|
146
|
-
|
|
42
|
+
Rebuild after changing native dependencies or plugin options. For iOS capabilities and plugin options, see [Expo setup](docs/guide/expo.md).
|
|
147
43
|
|
|
148
|
-
|
|
44
|
+
### React Native CLI
|
|
149
45
|
|
|
150
|
-
|
|
46
|
+
<a id="ios"></a><a id="android"></a>
|
|
151
47
|
|
|
48
|
+
- **iOS:** run `pod install`, then configure [NFC capabilities and usage description](docs/guide/ios.md).
|
|
49
|
+
- **Android:** the module is autolinked; check [NFC permissions and device support](docs/guide/android.md), then rebuild the app.
|
|
152
50
|
|
|
153
|
-
|
|
51
|
+
<a id="gettingstarted"></a><a id="usageconcept"></a>
|
|
154
52
|
|
|
155
|
-
|
|
53
|
+
## Read an NDEF tag
|
|
156
54
|
|
|
157
|
-
|
|
55
|
+
Call this function from a user action. It prevents overlapping scans and awaits cleanup before allowing another request.
|
|
158
56
|
|
|
159
57
|
```javascript
|
|
160
|
-
import React from 'react';
|
|
161
|
-
import {View, Text, TouchableOpacity, StyleSheet} from 'react-native';
|
|
162
58
|
import NfcManager, {NfcTech} from 'react-native-nfc-manager';
|
|
163
59
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
60
|
+
let scanning = false;
|
|
61
|
+
|
|
62
|
+
async function readNdef() {
|
|
63
|
+
if (scanning) return;
|
|
64
|
+
scanning = true;
|
|
65
|
+
let requestAttempted = false;
|
|
66
|
+
try {
|
|
67
|
+
await NfcManager.start();
|
|
68
|
+
requestAttempted = true;
|
|
69
|
+
await NfcManager.requestTechnology(NfcTech.Ndef);
|
|
70
|
+
const tag = await NfcManager.getTag();
|
|
71
|
+
console.log('NDEF records', tag?.ndefMessage ?? []);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.warn('NFC scan ended', error);
|
|
74
|
+
} finally {
|
|
169
75
|
try {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
console.warn('
|
|
175
|
-
} catch (ex) {
|
|
176
|
-
console.warn('Oops!', ex);
|
|
76
|
+
if (requestAttempted) {
|
|
77
|
+
await NfcManager.cancelTechnologyRequest();
|
|
78
|
+
}
|
|
79
|
+
} catch (cleanupError) {
|
|
80
|
+
console.warn('NFC cleanup failed', cleanupError);
|
|
177
81
|
} finally {
|
|
178
|
-
|
|
179
|
-
NfcManager.cancelTechnologyRequest();
|
|
82
|
+
scanning = false;
|
|
180
83
|
}
|
|
181
84
|
}
|
|
182
|
-
|
|
183
|
-
return (
|
|
184
|
-
<View style={styles.wrapper}>
|
|
185
|
-
<TouchableOpacity onPress={readNdef}>
|
|
186
|
-
<Text>Scan a Tag</Text>
|
|
187
|
-
</TouchableOpacity>
|
|
188
|
-
</View>
|
|
189
|
-
);
|
|
190
85
|
}
|
|
191
|
-
|
|
192
|
-
const styles = StyleSheet.create({
|
|
193
|
-
wrapper: {
|
|
194
|
-
flex: 1,
|
|
195
|
-
justifyContent: 'center',
|
|
196
|
-
alignItems: 'center',
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
export default App;
|
|
201
86
|
```
|
|
202
87
|
|
|
88
|
+
For a complete React screen and session lifecycle, see [reading NDEF tags](docs/guide/reading-ndef.md).
|
|
203
89
|
|
|
90
|
+
<a id="nfccompatibility"></a>
|
|
204
91
|
|
|
205
|
-
##
|
|
206
|
-
|
|
207
|
-
<a name="docs"></a>
|
|
208
|
-
|
|
209
|
-
Check the full documentation that contains `examples`, `faq` and other topics like `Expo` in our [Wiki](https://github.com/revtel/react-native-nfc-manager/wiki)
|
|
210
|
-
|
|
211
|
-
## Development Example
|
|
212
|
-
|
|
213
|
-
<a name="development-example"></a>
|
|
214
|
-
|
|
215
|
-
For local library development and physical-device NFC testing, use the React Native 0.84 New Architecture example app in [`example/`](./example). See [example/README.md](./example/README.md).
|
|
216
|
-
|
|
217
|
-
The example Jest suite mocks the native module and verifies application interactions only. It does not verify NFC hardware. Android and iOS compiler builds and physical-device checks are separate release gates.
|
|
218
|
-
|
|
219
|
-
### Build (TypeScript)
|
|
220
|
-
|
|
221
|
-
This project now uses a TypeScript build flow and emits distributable JavaScript to [`dist/`](./dist):
|
|
222
|
-
|
|
223
|
-
```shell
|
|
224
|
-
npm run build
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
For package publishing, `prepack` runs the build automatically.
|
|
228
|
-
|
|
229
|
-
### Routine CI
|
|
230
|
-
|
|
231
|
-
Routine CI uses Node.js 22 and runs dependency installation, the TypeScript build, lint, root Jest tests, and type checking. It deliberately does not run Android or iOS builds.
|
|
232
|
-
|
|
233
|
-
## Nfc Compatibility
|
|
234
|
-
|
|
235
|
-
<a name="nfccompatibility"></a>
|
|
236
|
-
|
|
237
|
-
|NFC Technologies | Android | iOS |
|
|
238
|
-
|--- |--- |--- |
|
|
239
|
-
| `Ndef` | ✅ | ✅ |
|
|
240
|
-
| `NfcA` | ✅ | ✅ |
|
|
241
|
-
| `IsoDep` | ✅ | ✅ |
|
|
242
|
-
| `NfcB` | ✅ | ❌ |
|
|
243
|
-
| `NfcF` | ✅ | ❌ |
|
|
244
|
-
| `NfcV` | ✅ | ❌ |
|
|
245
|
-
| `MifareClassic` | ✅ | ❌ |
|
|
246
|
-
| `MifareUltralight`| ✅ | ❌ |
|
|
247
|
-
| `MifareIOS` | ❌ | ✅ |
|
|
248
|
-
| `Iso15693IOS` | ❌ | ✅ |
|
|
249
|
-
| `FelicaIOS` | ❌ | ✅ |
|
|
250
|
-
|
|
251
|
-
This table describes the intended platform API availability. It is not a record of the devices, OS versions, or tag technologies verified for a particular release; see the [Support Policy](./docs/SUPPORT_POLICY.md) for evidence labels and limitations.
|
|
252
|
-
|
|
253
|
-
## Usage concept
|
|
254
|
-
|
|
255
|
-
<a name="usageconcept"></a>
|
|
256
|
-
|
|
257
|
-
In higher level, there're 4 steps to use this library:
|
|
258
|
-
|
|
259
|
-
0. (Recommended but not necessary) Before all next steps, use `NfcManager.start()` to start listen a tag.
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
1. Request your particular NFC technologies through `NfcManager.requestTechnology`. Let's request `Ndef` techonogy.
|
|
263
|
-
|
|
264
|
-
```javascript
|
|
265
|
-
NfcManager.requestTechnology(NfcTech.Ndef);
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
2. Select the proper NFC technology handler, which is implemented as getter in main `NfcManager` object.
|
|
269
|
-
|
|
270
|
-
```javascript
|
|
271
|
-
NfcManager.ndefHandler
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
3. Call specific methods on the NFC technology handler.
|
|
275
|
-
|
|
276
|
-
```javascript
|
|
277
|
-
NfcManager.ndefHandler.getNdefMessage()
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
4. Clean up your tech registration through:
|
|
281
|
-
|
|
282
|
-
```javascript
|
|
283
|
-
NfcManager.cancelTechnologyRequest()
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
## API
|
|
288
|
-
|
|
289
|
-
<a name="api"></a>
|
|
290
|
-
|
|
291
|
-
The following table shows the handler for each technology, so if you need to use a technology, go to [index.d.ts](index.d.ts) and search for it.
|
|
292
|
-
|
|
293
|
-
|NFC Technologies | Handlers |
|
|
294
|
-
|--- |--- |
|
|
295
|
-
| `Ndef` | `NdefHandler` |
|
|
296
|
-
| `NfcA` | `NfcAHandler` |
|
|
297
|
-
| `IsoDep` | `IsoDepHandler` |
|
|
298
|
-
| `NfcB` | - |
|
|
299
|
-
| `NfcF` | - |
|
|
300
|
-
| `NfcV` | `NfcVHandler` |
|
|
301
|
-
| `MifareClassic` | `MifareClassicHandlerAndroid` |
|
|
302
|
-
| `MifareUltralight`| `MifareUltralightHandlerAndroid` |
|
|
303
|
-
| `MifareIOS` | - |
|
|
304
|
-
| `Iso15693IOS` | `Iso15693HandlerIOS` |
|
|
305
|
-
| `FelicaIOS` | - |
|
|
92
|
+
## Technology support
|
|
306
93
|
|
|
94
|
+
| Technology | Android | iOS |
|
|
95
|
+
| --- | --- | --- |
|
|
96
|
+
| NDEF, NFC-A, ISO-DEP | ✅ | ✅ |
|
|
97
|
+
| NFC-V / ISO 15693 | `NfcV` | `Iso15693IOS` |
|
|
98
|
+
| MIFARE | `MifareClassic`, `MifareUltralight` | `MifareIOS` |
|
|
99
|
+
| FeliCa | `NfcF` | `FelicaIOS` |
|
|
307
100
|
|
|
308
|
-
|
|
101
|
+
See the [full technology and handler table](docs/reference/compatibility.md). Actual tag support depends on the device and OS.
|
|
309
102
|
|
|
310
|
-
<a
|
|
103
|
+
<a id="docs"></a><a id="api"></a>
|
|
311
104
|
|
|
312
|
-
|
|
105
|
+
## Documentation
|
|
313
106
|
|
|
314
|
-
|
|
315
|
-
<img alt="react-native-nfc-rewriter" src="./images/Apple-App-Store-Icon.png" width="250">
|
|
316
|
-
</a>
|
|
107
|
+
Start with the [v4 documentation index](docs/index.md).
|
|
317
108
|
|
|
318
|
-
|
|
109
|
+
- [Installation and runtime requirements](docs/guide/installation.md)
|
|
110
|
+
- [Expo setup](docs/guide/expo.md) · [iOS setup](docs/guide/ios.md) · [Android setup](docs/guide/android.md)
|
|
111
|
+
- [API and handlers](docs/reference/api.md)
|
|
112
|
+
- [Expo troubleshooting](docs/EXPO_TROUBLESHOOTING.md)
|
|
113
|
+
- [Support policy](docs/SUPPORT_POLICY.md) · [Changelog](CHANGELOG.md)
|
|
319
114
|
|
|
320
|
-
<a
|
|
321
|
-
<img alt="react-native-nfc-rewriter" src="./images/google-play-icon.jpeg" width="250">
|
|
322
|
-
</a>
|
|
115
|
+
<a id="development-example"></a><a id="appdemo"></a><a id="learn"></a>
|
|
323
116
|
|
|
324
|
-
##
|
|
117
|
+
## Examples and contributing
|
|
325
118
|
|
|
326
|
-
|
|
119
|
+
The [development example](example/README.md) exercises the New Architecture API. [Contributing](docs/CONTRIBUTING.md) includes build instructions and the NFC ReWriter app.
|
|
327
120
|
|
|
328
|
-
|
|
329
|
-
- Free course (1 hour) about basic NFC setup and concept [here](https://www.youtube.com/watch?v=rAS-DvNUFck)
|
|
330
|
-
- Full course (3 hours) for more (NDEF, Deep Linking, NTAG password protection, signature with UID) [here](https://www.newline.co/courses/newline-guide-to-nfcs-with-react-native)
|
|
121
|
+
Created by [whitedogg13](https://github.com/whitedogg13).
|
|
@@ -7,6 +7,7 @@ import android.nfc.NdefMessage;
|
|
|
7
7
|
import android.nfc.Tag;
|
|
8
8
|
import android.nfc.tech.Ndef;
|
|
9
9
|
import android.nfc.tech.NdefFormatable;
|
|
10
|
+
import android.nfc.tech.TagTechnology;
|
|
10
11
|
import android.os.Parcelable;
|
|
11
12
|
import android.util.Log;
|
|
12
13
|
|
|
@@ -16,6 +17,7 @@ import com.facebook.react.bridge.ReadableArray;
|
|
|
16
17
|
import com.facebook.react.bridge.ReadableMap;
|
|
17
18
|
import com.facebook.react.bridge.WritableMap;
|
|
18
19
|
|
|
20
|
+
import org.json.JSONArray;
|
|
19
21
|
import org.json.JSONException;
|
|
20
22
|
import org.json.JSONObject;
|
|
21
23
|
|
|
@@ -81,8 +83,19 @@ class NdefHandler {
|
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
try {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
TagTechnology techHandle = techRequest.getTechHandle();
|
|
87
|
+
if (!(techHandle instanceof Ndef)) {
|
|
88
|
+
callback.invoke(ERR_API_NOT_SUPPORT);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
Ndef ndef = (Ndef) techHandle;
|
|
93
|
+
if (!ndef.isConnected()) {
|
|
94
|
+
callback.invoke(ERR_NO_TECH_REQ);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
WritableMap parsed = ndefToReact(ndef, ndef.getNdefMessage());
|
|
86
99
|
callback.invoke(null, parsed);
|
|
87
100
|
} catch (Exception ex) {
|
|
88
101
|
Log.d(LOG_TAG, ex.toString());
|
|
@@ -316,6 +329,17 @@ class NdefHandler {
|
|
|
316
329
|
}
|
|
317
330
|
}
|
|
318
331
|
|
|
332
|
+
static WritableMap ndefToReact(Ndef ndef, NdefMessage message) {
|
|
333
|
+
try {
|
|
334
|
+
JSONObject json = Util.ndefToJSON(ndef);
|
|
335
|
+
json.put("ndefMessage", message == null ? new JSONArray() : Util.messageToJSON(message));
|
|
336
|
+
return Util.jsonToReact(json);
|
|
337
|
+
} catch (JSONException ex) {
|
|
338
|
+
Log.e(LOG_TAG, "Failed to convert ndef into json", ex);
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
319
343
|
static WritableMap ndefToReact(Tag tag, Parcelable[] messages) {
|
|
320
344
|
try {
|
|
321
345
|
Ndef ndef = tag != null ? Ndef.get(tag) : null;
|
|
@@ -5,7 +5,10 @@ import android.content.pm.PackageManager;
|
|
|
5
5
|
import android.nfc.NdefMessage;
|
|
6
6
|
import android.nfc.NdefRecord;
|
|
7
7
|
import android.nfc.Tag;
|
|
8
|
+
import android.nfc.tech.IsoDep;
|
|
8
9
|
import android.nfc.tech.Ndef;
|
|
10
|
+
import android.nfc.tech.NfcA;
|
|
11
|
+
import android.nfc.tech.NfcV;
|
|
9
12
|
import android.os.Build;
|
|
10
13
|
import android.util.Log;
|
|
11
14
|
|
|
@@ -163,8 +166,7 @@ public class Util {
|
|
|
163
166
|
Tag tag = ndef.getTag();
|
|
164
167
|
// tag is going to be null for NDEF_FORMATABLE until NfcUtil.parseMessage is refactored
|
|
165
168
|
if (tag != null) {
|
|
166
|
-
json
|
|
167
|
-
json.put("techTypes", new JSONArray(Arrays.asList(tag.getTechList())));
|
|
169
|
+
json = tagToJSON(tag);
|
|
168
170
|
}
|
|
169
171
|
|
|
170
172
|
json.put("type", translateType(ndef.getType()));
|
|
@@ -199,10 +201,80 @@ public class Util {
|
|
|
199
201
|
} catch (JSONException e) {
|
|
200
202
|
Log.e(TAG, "Failed to convert tag into json: " + tag, e);
|
|
201
203
|
}
|
|
204
|
+
|
|
205
|
+
addCachedTechnologyMetadata(json, tag);
|
|
202
206
|
}
|
|
203
207
|
return json;
|
|
204
208
|
}
|
|
205
209
|
|
|
210
|
+
private static void addCachedTechnologyMetadata(JSONObject json, Tag tag) {
|
|
211
|
+
NfcA nfcA = null;
|
|
212
|
+
try {
|
|
213
|
+
nfcA = NfcA.get(tag);
|
|
214
|
+
} catch (RuntimeException e) {
|
|
215
|
+
Log.w(TAG, "Failed to obtain cached NFC-A metadata", e);
|
|
216
|
+
}
|
|
217
|
+
if (nfcA != null) {
|
|
218
|
+
try {
|
|
219
|
+
byte[] atqa = nfcA.getAtqa();
|
|
220
|
+
if (atqa != null) {
|
|
221
|
+
json.put("atqa", byteArrayToJSON(atqa));
|
|
222
|
+
}
|
|
223
|
+
} catch (Exception e) {
|
|
224
|
+
Log.w(TAG, "Failed to read cached NFC-A ATQA", e);
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
json.put("sak", nfcA.getSak() & 0xFFFF);
|
|
228
|
+
} catch (Exception e) {
|
|
229
|
+
Log.w(TAG, "Failed to read cached NFC-A SAK", e);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
NfcV nfcV = null;
|
|
234
|
+
try {
|
|
235
|
+
nfcV = NfcV.get(tag);
|
|
236
|
+
} catch (RuntimeException e) {
|
|
237
|
+
Log.w(TAG, "Failed to obtain cached NFC-V metadata", e);
|
|
238
|
+
}
|
|
239
|
+
if (nfcV != null) {
|
|
240
|
+
try {
|
|
241
|
+
json.put("dsfid", nfcV.getDsfId() & 0xFF);
|
|
242
|
+
} catch (Exception e) {
|
|
243
|
+
Log.w(TAG, "Failed to read cached NFC-V DSFID", e);
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
json.put("responseFlags", nfcV.getResponseFlags() & 0xFF);
|
|
247
|
+
} catch (Exception e) {
|
|
248
|
+
Log.w(TAG, "Failed to read cached NFC-V response flags", e);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
IsoDep isoDep = null;
|
|
253
|
+
try {
|
|
254
|
+
isoDep = IsoDep.get(tag);
|
|
255
|
+
} catch (RuntimeException e) {
|
|
256
|
+
Log.w(TAG, "Failed to obtain cached ISO-DEP metadata", e);
|
|
257
|
+
}
|
|
258
|
+
if (isoDep != null) {
|
|
259
|
+
try {
|
|
260
|
+
byte[] historicalBytes = isoDep.getHistoricalBytes();
|
|
261
|
+
if (historicalBytes != null) {
|
|
262
|
+
json.put("historicalBytes", byteArrayToJSON(historicalBytes));
|
|
263
|
+
}
|
|
264
|
+
} catch (Exception e) {
|
|
265
|
+
Log.w(TAG, "Failed to read cached ISO-DEP historical bytes", e);
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
byte[] hiLayerResponse = isoDep.getHiLayerResponse();
|
|
269
|
+
if (hiLayerResponse != null) {
|
|
270
|
+
json.put("hiLayerResponse", byteArrayToJSON(hiLayerResponse));
|
|
271
|
+
}
|
|
272
|
+
} catch (Exception e) {
|
|
273
|
+
Log.w(TAG, "Failed to read cached ISO-DEP higher-layer response", e);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
206
278
|
static WritableMap tagToReact(Tag tag) {
|
|
207
279
|
try {
|
|
208
280
|
JSONObject json = tagToJSON(tag);
|
package/app.plugin.js
CHANGED
|
@@ -42,9 +42,9 @@ function addValuesToArray(obj, key, values) {
|
|
|
42
42
|
function withIosNfcEntitlement(c, {includeNdefEntitlement}) {
|
|
43
43
|
return withEntitlementsPlist(c, (config) => {
|
|
44
44
|
// Add the required formats
|
|
45
|
-
let entitlements = ['NDEF', 'TAG']
|
|
45
|
+
let entitlements = ['NDEF', 'TAG'];
|
|
46
46
|
if (includeNdefEntitlement === false) {
|
|
47
|
-
entitlements = ['TAG']
|
|
47
|
+
entitlements = ['TAG'];
|
|
48
48
|
}
|
|
49
49
|
config.modResults = addValuesToArray(
|
|
50
50
|
config.modResults,
|
|
@@ -90,18 +90,17 @@ function withNfc(config, props = {}) {
|
|
|
90
90
|
config = withIosNfcSelectIdentifiers(config, {selectIdentifiers});
|
|
91
91
|
config = withIosNfcSystemCodes(config, {systemCodes});
|
|
92
92
|
|
|
93
|
-
// We start to support Android 12 from v3.11.1, and you will need to update compileSdkVersion to 31,
|
|
94
|
-
// otherwise the build will fail:
|
|
95
|
-
config = AndroidConfig.Version.withBuildScriptExtMinimumVersion(config, {
|
|
96
|
-
name: 'compileSdkVersion',
|
|
97
|
-
minVersion: 31,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
93
|
if (nfcPermission !== false) {
|
|
101
94
|
config = withIosPermission(config, props);
|
|
102
95
|
config = AndroidConfig.Permissions.withPermissions(config, [
|
|
103
96
|
'android.permission.NFC',
|
|
104
97
|
]);
|
|
98
|
+
} else {
|
|
99
|
+
// The library manifest declares NFC for React Native CLI consumers. Block it
|
|
100
|
+
// explicitly when an Expo consumer opts out so manifest merging removes it.
|
|
101
|
+
config = AndroidConfig.Permissions.withBlockedPermissions(config, [
|
|
102
|
+
'android.permission.NFC',
|
|
103
|
+
]);
|
|
105
104
|
}
|
|
106
105
|
return config;
|
|
107
106
|
}
|
package/dist/ndef-lib/ndef.js
CHANGED
|
@@ -97,15 +97,14 @@ function decodeNdefMessage(ndefBytes) {
|
|
|
97
97
|
il: (tnf_byte & 0x8) !== 0,
|
|
98
98
|
tnf: tnf_byte & 0x7,
|
|
99
99
|
});
|
|
100
|
-
//
|
|
100
|
+
// Buffer extends Uint8Array; copy only the supplied view before parsing.
|
|
101
101
|
let bytes;
|
|
102
|
-
if (ndefBytes instanceof
|
|
103
|
-
bytes =
|
|
102
|
+
if (Array.isArray(ndefBytes) || ndefBytes instanceof Uint8Array) {
|
|
103
|
+
bytes = Array.from(ndefBytes);
|
|
104
104
|
}
|
|
105
105
|
else {
|
|
106
|
-
throw new Error('ndef.decodeMessage requires a Buffer or an Array of bytes');
|
|
106
|
+
throw new Error('ndef.decodeMessage requires a Buffer, Uint8Array, or an Array of bytes');
|
|
107
107
|
}
|
|
108
|
-
bytes = bytes.slice(0); // clone since parsing is destructive
|
|
109
108
|
let ndef_message = [], tnf_byte, header, type_length = 0, payload_length = 0, id_length = 0, record_type = [], id = [], payload = [];
|
|
110
109
|
while (bytes.length) {
|
|
111
110
|
tnf_byte = bytes.shift();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ndef.js","sourceRoot":"","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MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;QAChC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAE1C,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;QAE1E,IAAI,MAAM,CAAC,EAAE,EAAE;YACb,MAAM;SACP,CAAC,eAAe;KAClB;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAkB,EAAE,GAAW,EAAE,IAAY;IACtE,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE;QACtB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC9B,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;SACjD;aAAM;YACL,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;SAC7B;KACF;IACD,OAAO,MAAM,CAAC,GAAG,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,OAAO,GAAG;IACf,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;CAClB,CAAC"}
|
package/dist/ndef-lib/util.js
CHANGED
|
@@ -23,8 +23,16 @@ function _utf8ArrayToStr(data) {
|
|
|
23
23
|
}
|
|
24
24
|
ch = (ch << 6) | (chx & 0x3f);
|
|
25
25
|
}
|
|
26
|
+
// A four-byte sequence can decode above the Unicode maximum, which is
|
|
27
|
+
// not a valid code point. Reject it like the other malformed cases
|
|
28
|
+
// rather than letting String.fromCodePoint throw a RangeError.
|
|
29
|
+
if (ch > 0x10ffff) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
26
32
|
}
|
|
27
|
-
|
|
33
|
+
// fromCharCode truncates to 16 bits, which silently corrupts anything
|
|
34
|
+
// outside the BMP: U+1F4A9 would come back as U+F4A9.
|
|
35
|
+
str += String.fromCodePoint(ch);
|
|
28
36
|
}
|
|
29
37
|
return str;
|
|
30
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../ndef-lib/util.ts"],"names":[],"mappings":";AAAA,eAAe;AACf,6BAA6B;AAC7B,EAAE;;AAKF,4GAA4G;AAC5G,SAAS,eAAe,CAAC,IAAe;IACtC,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9C,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;IACxB,IAAI,GAAG,GAAG,EAAE,CAAC;IAEb,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,GAAI;QACnC,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACvB,IAAI,EAAE,GAAG,IAAI,EAAE;YACb,IAAI,KAAK,GAAG,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;YAC3C,IAAI,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,GAAG,KAAK,EAAE;gBACnD,OAAO,IAAI,CAAC;aACb;YAED,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;YAC1B,OAAO,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE;gBAC5B,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;gBACxB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;oBACzB,OAAO,IAAI,CAAC;iBACb;gBAED,EAAE,GAAG,CA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|
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.callNative = exports.NfcManagerEmitter = exports.NativeNfcManager = void 0;
|
|
4
4
|
const react_native_1 = require("react-native");
|
|
5
|
+
const runtimeCompatibility_1 = require("./runtimeCompatibility");
|
|
5
6
|
const reactNativeGlobal = global;
|
|
6
7
|
const isTurboModuleEnabled = reactNativeGlobal['RN$Bridgeless'] === true ||
|
|
7
8
|
reactNativeGlobal.__turboModuleProxy != null;
|
|
9
|
+
(0, runtimeCompatibility_1.warnRuntimeCompatibility)();
|
|
8
10
|
const nativeModules = react_native_1.NativeModules || {};
|
|
9
11
|
const NativeNfcManager = (isTurboModuleEnabled
|
|
10
|
-
?
|
|
12
|
+
? react_native_1.TurboModuleRegistry.get('NfcManager')
|
|
11
13
|
: nativeModules.NfcManager);
|
|
12
14
|
exports.NativeNfcManager = NativeNfcManager;
|
|
15
|
+
if (!NativeNfcManager) {
|
|
16
|
+
throw new Error('[react-native-nfc-manager] The NfcManager native module is unavailable. ' +
|
|
17
|
+
'Verify native linking and rebuild the native app after installing this package. ' +
|
|
18
|
+
'Expo apps require a Development Build; Expo Go cannot load this module.');
|
|
19
|
+
}
|
|
13
20
|
const legacyNfcManagerEmitter = typeof react_native_1.NativeEventEmitter === 'function'
|
|
14
21
|
? new react_native_1.NativeEventEmitter(NativeNfcManager)
|
|
15
22
|
: { addListener: () => ({ remove: () => { } }) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeNfcManager.js","sourceRoot":"","sources":["../../src/NativeNfcManager.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,+
|
|
1
|
+
{"version":3,"file":"NativeNfcManager.js","sourceRoot":"","sources":["../../src/NativeNfcManager.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,+CAAoF;AACpF,iEAAgE;AAmBhE,MAAM,iBAAiB,GAAG,MAGzB,CAAC;AACF,MAAM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C;AA+BwB,8CAAiB;AA7B3C,SAAS,UAAU,CAAc,IAAY,EAAE,SAAoB,EAAE;IACnE,MAAM,YAAY,GAAG,gBAAgB,CAAC,IAAI,CAA6B,CAAC;IAExE,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,GAAG,CAAC,CAAC;KACrD;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IAED,MAAM,cAAc,GAAG,CACrB,OAA4C,EAC5C,MAAkC,EAClC,EAAE,CAAC,CAAC,GAAY,EAAE,MAAS,EAAE,EAAE;QAC/B,IAAI,GAAG,EAAE;YACP,MAAM,CAAC,GAAG,CAAC,CAAC;SACb;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC;SACjB;IACH,CAAC,CAAC;IAEF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjD,MAAM,WAAW,GAAG,CAAC,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC1C,YAAY,CAAC,GAAG,WAAW,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC;AAE4C,gCAAU"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.warnRuntimeCompatibility = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const runtime = global;
|
|
6
|
+
let warned = false;
|
|
7
|
+
// This is a diagnostic, not a native-module availability check.
|
|
8
|
+
function warnRuntimeCompatibility() {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (typeof __DEV__ === 'undefined' || !__DEV__ || warned) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const version = (_a = react_native_1.Platform.constants) === null || _a === void 0 ? void 0 : _a.reactNativeVersion;
|
|
14
|
+
if (!version ||
|
|
15
|
+
!Number.isInteger(version.major) ||
|
|
16
|
+
!Number.isInteger(version.minor) ||
|
|
17
|
+
version.major < 0 ||
|
|
18
|
+
version.minor < 0) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const detected = `${version.major}.${version.minor}.${(_b = version.patch) !== null && _b !== void 0 ? _b : 0}`;
|
|
22
|
+
let message;
|
|
23
|
+
if (version.major === 0 && version.minor < 76) {
|
|
24
|
+
message = `React Native ${detected} is unsupported. v4 requires React Native 0.76+ with the New Architecture. Upgrade React Native and rebuild the native app.`;
|
|
25
|
+
}
|
|
26
|
+
else if (version.major === 0 &&
|
|
27
|
+
version.minor < 82 &&
|
|
28
|
+
runtime['RN$Bridgeless'] !== true &&
|
|
29
|
+
runtime.nativeFabricUIManager == null &&
|
|
30
|
+
runtime.__turboModuleProxy == null) {
|
|
31
|
+
message = `React Native ${detected} has no New Architecture runtime detected. v4 requires the New Architecture. Enable it in your app and rebuild the native app.`;
|
|
32
|
+
}
|
|
33
|
+
if (message) {
|
|
34
|
+
warned = true;
|
|
35
|
+
console.warn(`[react-native-nfc-manager] ${message}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.warnRuntimeCompatibility = warnRuntimeCompatibility;
|
|
39
|
+
//# sourceMappingURL=runtimeCompatibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeCompatibility.js","sourceRoot":"","sources":["../../src/runtimeCompatibility.ts"],"names":[],"mappings":";;;AAAA,+CAAsC;AAEtC,MAAM,OAAO,GAAG,MAIf,CAAC;AAEF,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,gEAAgE;AAChE,SAAgB,wBAAwB;;IACtC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,CAAC,OAAO,IAAI,MAAM,EAAE;QACxD,OAAO;KACR;IAED,MAAM,OAAO,GAAG,MAAA,uBAAQ,CAAC,SAAS,0CAAE,kBAAkB,CAAC;IACvD,IACE,CAAC,OAAO;QACR,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;QAChC,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;QAChC,OAAO,CAAC,KAAK,GAAG,CAAC;QACjB,OAAO,CAAC,KAAK,GAAG,CAAC,EACjB;QACA,OAAO;KACR;IAED,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,MAAA,OAAO,CAAC,KAAK,mCAAI,CAAC,EAAE,CAAC;IAC3E,IAAI,OAA2B,CAAC;IAChC,IAAI,OAAO,CAAC,KAAK,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,GAAG,EAAE,EAAE;QAC7C,OAAO,GAAG,gBAAgB,QAAQ,6HAA6H,CAAC;KACjK;SAAM,IACL,OAAO,CAAC,KAAK,KAAK,CAAC;QACnB,OAAO,CAAC,KAAK,GAAG,EAAE;QAClB,OAAO,CAAC,eAAe,CAAC,KAAK,IAAI;QACjC,OAAO,CAAC,qBAAqB,IAAI,IAAI;QACrC,OAAO,CAAC,kBAAkB,IAAI,IAAI,EAClC;QACA,OAAO,GAAG,gBAAgB,QAAQ,gIAAgI,CAAC;KACpK;IAED,IAAI,OAAO,EAAE;QACX,MAAM,GAAG,IAAI,CAAC;QACd,OAAO,CAAC,IAAI,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;KACvD;AACH,CAAC;AAlCD,4DAkCC"}
|
package/index.d.ts
CHANGED
|
@@ -64,18 +64,48 @@ declare module 'react-native-nfc-manager' {
|
|
|
64
64
|
type TNF = 0x0 | 0x01 | 0x02 | 0x03 | 0x04 | 0x05 | 0x06 | 0x07;
|
|
65
65
|
|
|
66
66
|
export interface NdefRecord {
|
|
67
|
-
|
|
67
|
+
/** Android returns a hex string; iOS returns a byte array. */
|
|
68
|
+
id?: number[] | string;
|
|
68
69
|
tnf: TNF;
|
|
69
70
|
type: number[] | string;
|
|
70
71
|
payload: number[];
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
export interface TagEvent {
|
|
74
|
-
|
|
75
|
+
/** Absent when no NDEF message is available; do not assume an empty array. */
|
|
76
|
+
ndefMessage?: NdefRecord[];
|
|
75
77
|
maxSize?: number;
|
|
76
78
|
type?: string;
|
|
77
79
|
techTypes?: string[];
|
|
78
80
|
id?: string;
|
|
81
|
+
/** Android NDEF tag metadata. */
|
|
82
|
+
isWritable?: boolean;
|
|
83
|
+
/** Android may return null when this capability cannot be determined. */
|
|
84
|
+
canMakeReadOnly?: boolean | null;
|
|
85
|
+
/** Android NFC-A discovery metadata; bytes are unsigned (0–255). */
|
|
86
|
+
atqa?: number[];
|
|
87
|
+
/** Android NFC-A discovery metadata. */
|
|
88
|
+
sak?: number;
|
|
89
|
+
/** Android NFC-V discovery metadata; unsigned byte (0–255). */
|
|
90
|
+
dsfid?: number;
|
|
91
|
+
/** Android NFC-V discovery metadata; unsigned byte (0–255). */
|
|
92
|
+
responseFlags?: number;
|
|
93
|
+
/** Android ISO-DEP discovery metadata; bytes are unsigned (0–255). */
|
|
94
|
+
hiLayerResponse?: number[];
|
|
95
|
+
/** iOS tag technology name. */
|
|
96
|
+
tech?: string;
|
|
97
|
+
/** iOS FeliCa metadata. */
|
|
98
|
+
idm?: string;
|
|
99
|
+
systemCode?: string;
|
|
100
|
+
/** iOS ISO 7816 metadata. */
|
|
101
|
+
initialSelectedAID?: string;
|
|
102
|
+
/** iOS ISO 7816 or Android ISO-DEP discovery metadata. */
|
|
103
|
+
historicalBytes?: number[];
|
|
104
|
+
/** iOS ISO 7816 metadata. */
|
|
105
|
+
applicationData?: number[];
|
|
106
|
+
/** iOS ISO 15693 metadata. */
|
|
107
|
+
icManufacturerCode?: number;
|
|
108
|
+
icSerialNumber?: number[];
|
|
79
109
|
}
|
|
80
110
|
|
|
81
111
|
export interface RegisterTagEventOpts {
|
|
@@ -412,7 +442,7 @@ declare module 'react-native-nfc-manager' {
|
|
|
412
442
|
isType(record: NdefRecord, tnf: TNF, type: string): boolean;
|
|
413
443
|
stringify(data: number[], separator: string): string;
|
|
414
444
|
encodeMessage(records: NdefRecord[]): number[];
|
|
415
|
-
decodeMessage(bytes: number[]): NdefRecord[];
|
|
445
|
+
decodeMessage(bytes: number[] | Uint8Array): NdefRecord[];
|
|
416
446
|
textRecord(text: string, lang?: ISOLangCode, encoding?: unknown): NdefRecord;
|
|
417
447
|
uriRecord(uri: URI, id?: string | number[]): NdefRecord;
|
|
418
448
|
wifiSimpleRecord(credentials: WifiSimpleCredentials, id?: string | number[]): NdefRecord;
|
package/ios/NfcManager.mm
CHANGED
|
@@ -245,9 +245,9 @@ continueUserActivity:(NSUserActivity *)userActivity
|
|
|
245
245
|
[RNNfcManager sendCommandAPDU:apduData callback:callback];
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
- (void)iso15693_getSystemInfo:(
|
|
248
|
+
- (void)iso15693_getSystemInfo:(double)requestFlag callback:(nonnull RCTResponseSenderBlock)callback
|
|
249
249
|
{
|
|
250
|
-
[RNNfcManager iso15693GetSystemInfo
|
|
250
|
+
[RNNfcManager iso15693GetSystemInfo:@(requestFlag) callback:callback];
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
- (void)iso15693_readSingleBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback
|
|
@@ -348,6 +348,94 @@ continueUserActivity:(NSUserActivity *)userActivity
|
|
|
348
348
|
- (void)isEnabled:(RCTResponseSenderBlock)callback {
|
|
349
349
|
// bypass, Android's interface
|
|
350
350
|
}
|
|
351
|
+
|
|
352
|
+
- (void)goToNfcSetting:(RCTResponseSenderBlock)callback {
|
|
353
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
- (void)getLaunchTagEvent:(RCTResponseSenderBlock)callback {
|
|
357
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
- (void)setTimeout:(double)timeout callback:(RCTResponseSenderBlock)callback {
|
|
361
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
- (void)getTimeout:(RCTResponseSenderBlock)callback {
|
|
365
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
- (void)connect:(NSArray *)techs callback:(RCTResponseSenderBlock)callback {
|
|
369
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
- (void)close:(RCTResponseSenderBlock)callback {
|
|
373
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
- (void)transceive:(NSArray *)bytes callback:(RCTResponseSenderBlock)callback {
|
|
377
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
- (void)getMaxTransceiveLength:(RCTResponseSenderBlock)callback {
|
|
381
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
- (void)formatNdef:(NSArray *)bytes options:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback {
|
|
385
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
- (void)mifareUltralightReadPages:(double)pageOffset callback:(RCTResponseSenderBlock)callback {
|
|
389
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
- (void)mifareUltralightWritePage:(double)pageOffset bytes:(NSArray *)bytes callback:(RCTResponseSenderBlock)callback {
|
|
393
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
- (void)mifareClassicAuthenticateA:(double)sector key:(NSArray *)key callback:(RCTResponseSenderBlock)callback {
|
|
397
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
- (void)mifareClassicAuthenticateB:(double)sector key:(NSArray *)key callback:(RCTResponseSenderBlock)callback {
|
|
401
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
- (void)mifareClassicGetBlockCountInSector:(double)sector callback:(RCTResponseSenderBlock)callback {
|
|
405
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
- (void)mifareClassicGetSectorCount:(RCTResponseSenderBlock)callback {
|
|
409
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
- (void)mifareClassicSectorToBlock:(double)sector callback:(RCTResponseSenderBlock)callback {
|
|
413
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
- (void)mifareClassicReadBlock:(double)block callback:(RCTResponseSenderBlock)callback {
|
|
417
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
- (void)mifareClassicReadSector:(double)sector callback:(RCTResponseSenderBlock)callback {
|
|
421
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
- (void)mifareClassicWriteBlock:(double)block data:(NSArray *)data callback:(RCTResponseSenderBlock)callback {
|
|
425
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
- (void)mifareClassicIncrementBlock:(double)block value:(double)value callback:(RCTResponseSenderBlock)callback {
|
|
429
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
- (void)mifareClassicDecrementBlock:(double)block value:(double)value callback:(RCTResponseSenderBlock)callback {
|
|
433
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
- (void)mifareClassicTransferBlock:(double)block callback:(RCTResponseSenderBlock)callback {
|
|
437
|
+
callback(@[@"unsupported tag api", [NSNull null]]);
|
|
438
|
+
}
|
|
351
439
|
|
|
352
440
|
@end
|
|
353
441
|
|
package/ndef-lib/ndef.ts
CHANGED
|
@@ -141,7 +141,7 @@ function encodeNdefMessage(ndefRecords: NdefRecord[]): ByteArray {
|
|
|
141
141
|
return encoded;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
function decodeNdefMessage(ndefBytes: ByteArray): NdefRecord[] {
|
|
144
|
+
function decodeNdefMessage(ndefBytes: ByteArray | Uint8Array): NdefRecord[] {
|
|
145
145
|
const decodeTnf = (tnf_byte: number): TnfHeader => ({
|
|
146
146
|
mb: (tnf_byte & 0x80) !== 0,
|
|
147
147
|
me: (tnf_byte & 0x40) !== 0,
|
|
@@ -151,17 +151,16 @@ function decodeNdefMessage(ndefBytes: ByteArray): NdefRecord[] {
|
|
|
151
151
|
tnf: tnf_byte & 0x7,
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
-
//
|
|
154
|
+
// Buffer extends Uint8Array; copy only the supplied view before parsing.
|
|
155
155
|
let bytes: ByteArray;
|
|
156
|
-
if (ndefBytes instanceof
|
|
157
|
-
bytes =
|
|
156
|
+
if (Array.isArray(ndefBytes) || ndefBytes instanceof Uint8Array) {
|
|
157
|
+
bytes = Array.from(ndefBytes);
|
|
158
158
|
} else {
|
|
159
159
|
throw new Error(
|
|
160
|
-
'ndef.decodeMessage requires a Buffer or an Array of bytes',
|
|
160
|
+
'ndef.decodeMessage requires a Buffer, Uint8Array, or an Array of bytes',
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
bytes = bytes.slice(0); // clone since parsing is destructive
|
|
165
164
|
let ndef_message: NdefRecord[] = [],
|
|
166
165
|
tnf_byte,
|
|
167
166
|
header,
|
package/ndef-lib/util.ts
CHANGED
|
@@ -28,9 +28,18 @@ function _utf8ArrayToStr(data: ByteArray): string | null {
|
|
|
28
28
|
|
|
29
29
|
ch = (ch << 6) | (chx & 0x3f);
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
// A four-byte sequence can decode above the Unicode maximum, which is
|
|
33
|
+
// not a valid code point. Reject it like the other malformed cases
|
|
34
|
+
// rather than letting String.fromCodePoint throw a RangeError.
|
|
35
|
+
if (ch > 0x10ffff) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
|
|
40
|
+
// fromCharCode truncates to 16 bits, which silently corrupts anything
|
|
41
|
+
// outside the BMP: U+1F4A9 would come back as U+F4A9.
|
|
42
|
+
str += String.fromCodePoint(ch);
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
return str;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nfc-manager",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A NFC module for react native.",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/
|
|
9
|
+
"url": "https://github.com/revtel/react-native-nfc-manager.git"
|
|
10
10
|
},
|
|
11
11
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/
|
|
12
|
+
"url": "https://github.com/revtel/react-native-nfc-manager/issues"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"react-native",
|
|
@@ -39,17 +39,6 @@
|
|
|
39
39
|
"<rootDir>/example/"
|
|
40
40
|
]
|
|
41
41
|
},
|
|
42
|
-
"babel": {
|
|
43
|
-
"presets": [
|
|
44
|
-
"@babel/preset-env",
|
|
45
|
-
"@babel/preset-react",
|
|
46
|
-
"@babel/preset-typescript"
|
|
47
|
-
],
|
|
48
|
-
"plugins": [
|
|
49
|
-
"@babel/plugin-proposal-class-properties",
|
|
50
|
-
"@babel/plugin-transform-runtime"
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
42
|
"devDependencies": {
|
|
54
43
|
"@babel/core": "^7.12.10",
|
|
55
44
|
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
|
@@ -88,9 +77,24 @@
|
|
|
88
77
|
"test": "jest -i",
|
|
89
78
|
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
|
|
90
79
|
"verify:package": "npm run build && node scripts/verify-package-contents.js",
|
|
80
|
+
"verify:codegen": "node scripts/verify-codegen-compatibility.js",
|
|
81
|
+
"verify:codegen:version": "node scripts/verify-codegen-compatibility.js --version",
|
|
82
|
+
"verify:codegen:regression": "node scripts/verify-codegen-compatibility.js --version=0.77.3 --assert-beta8-regression",
|
|
83
|
+
"verify:native:support-floor": "node scripts/verify-native-support-floor.js",
|
|
84
|
+
"verify:native:support-floor:android": "node scripts/verify-native-support-floor.js --platform=android",
|
|
85
|
+
"verify:native:support-floor:ios": "node scripts/verify-native-support-floor.js --platform=ios",
|
|
86
|
+
"verify:expo": "node scripts/verify-expo-consumer.js",
|
|
87
|
+
"verify:expo:config": "node scripts/verify-expo-consumer.js --platform=config",
|
|
88
|
+
"verify:expo:android": "node scripts/verify-expo-consumer.js --platform=android",
|
|
89
|
+
"verify:expo:ios": "node scripts/verify-expo-consumer.js --platform=ios",
|
|
90
|
+
"prepare:expo:smoke": "node scripts/prepare-expo-smoke.js",
|
|
91
91
|
"prepack": "npm run build",
|
|
92
|
-
"release": "dotenv -- release
|
|
93
|
-
"release:beta": "release
|
|
92
|
+
"release": "dotenv -- node scripts/release.js stable",
|
|
93
|
+
"release:beta": "dotenv -- node scripts/release.js beta",
|
|
94
|
+
"test:example": "npm --prefix example test -- --runInBand --no-watchman",
|
|
95
|
+
"verify": "npm run build && npm run lint && npm run typecheck && npm test -- --runInBand --no-watchman && npm run test:example && node scripts/verify-package-contents.js",
|
|
96
|
+
"release:stable": "dotenv -- node scripts/release.js stable",
|
|
97
|
+
"test:publishing": "node --test scripts/trusted-publishing.test.cjs"
|
|
94
98
|
},
|
|
95
99
|
"codegenConfig": {
|
|
96
100
|
"name": "NativeNfcManagerSpec",
|
package/src/NativeNfcManager.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
import {NativeModules, NativeEventEmitter} from 'react-native';
|
|
2
|
+
import {NativeModules, NativeEventEmitter, TurboModuleRegistry} from 'react-native';
|
|
3
|
+
import {warnRuntimeCompatibility} from './runtimeCompatibility';
|
|
3
4
|
|
|
4
5
|
type NativeMethod = (...args: unknown[]) => void;
|
|
5
6
|
type NativeEventSubscription = {remove: () => void};
|
|
@@ -25,11 +26,21 @@ const reactNativeGlobal = global as typeof global & {
|
|
|
25
26
|
const isTurboModuleEnabled =
|
|
26
27
|
reactNativeGlobal['RN$Bridgeless'] === true ||
|
|
27
28
|
reactNativeGlobal.__turboModuleProxy != null;
|
|
29
|
+
warnRuntimeCompatibility();
|
|
30
|
+
|
|
28
31
|
const nativeModules = NativeModules || {};
|
|
29
32
|
const NativeNfcManager = (isTurboModuleEnabled
|
|
30
|
-
?
|
|
33
|
+
? TurboModuleRegistry.get('NfcManager')
|
|
31
34
|
: nativeModules.NfcManager) as NativeModule;
|
|
32
35
|
|
|
36
|
+
if (!NativeNfcManager) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
'[react-native-nfc-manager] The NfcManager native module is unavailable. ' +
|
|
39
|
+
'Verify native linking and rebuild the native app after installing this package. ' +
|
|
40
|
+
'Expo apps require a Development Build; Expo Go cannot load this module.',
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
const legacyNfcManagerEmitter: NativeEmitterLike =
|
|
34
45
|
typeof NativeEventEmitter === 'function'
|
|
35
46
|
? new NativeEventEmitter(NativeNfcManager)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {Platform} from 'react-native';
|
|
2
|
+
|
|
3
|
+
const runtime = global as typeof global & {
|
|
4
|
+
'RN$Bridgeless'?: boolean;
|
|
5
|
+
__turboModuleProxy?: unknown;
|
|
6
|
+
nativeFabricUIManager?: unknown;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
let warned = false;
|
|
10
|
+
|
|
11
|
+
// This is a diagnostic, not a native-module availability check.
|
|
12
|
+
export function warnRuntimeCompatibility(): void {
|
|
13
|
+
if (typeof __DEV__ === 'undefined' || !__DEV__ || warned) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const version = Platform.constants?.reactNativeVersion;
|
|
18
|
+
if (
|
|
19
|
+
!version ||
|
|
20
|
+
!Number.isInteger(version.major) ||
|
|
21
|
+
!Number.isInteger(version.minor) ||
|
|
22
|
+
version.major < 0 ||
|
|
23
|
+
version.minor < 0
|
|
24
|
+
) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const detected = `${version.major}.${version.minor}.${version.patch ?? 0}`;
|
|
29
|
+
let message: string | undefined;
|
|
30
|
+
if (version.major === 0 && version.minor < 76) {
|
|
31
|
+
message = `React Native ${detected} is unsupported. v4 requires React Native 0.76+ with the New Architecture. Upgrade React Native and rebuild the native app.`;
|
|
32
|
+
} else if (
|
|
33
|
+
version.major === 0 &&
|
|
34
|
+
version.minor < 82 &&
|
|
35
|
+
runtime['RN$Bridgeless'] !== true &&
|
|
36
|
+
runtime.nativeFabricUIManager == null &&
|
|
37
|
+
runtime.__turboModuleProxy == null
|
|
38
|
+
) {
|
|
39
|
+
message = `React Native ${detected} has no New Architecture runtime detected. v4 requires the New Architecture. Enable it in your app and rebuild the native app.`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (message) {
|
|
43
|
+
warned = true;
|
|
44
|
+
console.warn(`[react-native-nfc-manager] ${message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|