react-native-nfc-manager 4.0.0-beta.1 → 4.0.0-beta.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/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 +397 -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 +134 -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} +23 -9
- package/package.json +39 -21
- package/react-native-nfc-manager.podspec +3 -2
- package/specs/NativeNfcManager.ts +18 -4
- 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/specs/NativeNfcManager.d.ts +0 -6
- package/specs/NativeNfcManager.js +0 -3
- package/specs/NativeNfcManager.js.map +0 -1
- package/src/NativeNfcManager.js +0 -37
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# react-native-nfc-manager
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/react-native-nfc-manager)
|
|
4
|
-
[](https://github.com/revtel/react-native-nfc-manager/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/revtel/react-native-nfc-manager/issues)
|
|
6
6
|
|
|
7
7
|
Bring NFC feature to React Native. Inspired by [phonegap-nfc](https://github.com/chariotsolutions/phonegap-nfc) and [react-native-ble-manager](https://github.com/innoveit/react-native-ble-manager)
|
|
8
8
|
|
|
@@ -12,25 +12,87 @@ Made with ❤️ by [whitedogg13](https://github.com/whitedogg13) and [revteltec
|
|
|
12
12
|
|
|
13
13
|
> Special thanks to [javix64](https://github.com/javix64) for restructuring the documentation!
|
|
14
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](https://github.com/revtel/react-native-nfc-manager/blob/v4/docs/SUPPORT_POLICY.md) for official React Native version window, architecture targets, and verification matrix.
|
|
23
|
+
- Maintainers should follow [Release Validation](https://github.com/revtel/react-native-nfc-manager/blob/v4/docs/RELEASING.md) for Codegen, compiler, simulator, and physical-device evidence gates.
|
|
24
|
+
|
|
15
25
|
## Table of Contents
|
|
16
26
|
|
|
17
27
|
1. [Installation](#installation)
|
|
18
|
-
2. [
|
|
19
|
-
3. [
|
|
28
|
+
2. [Expo Development Builds](#expo-development-builds)
|
|
29
|
+
3. [Getting Started](#gettingstarted)
|
|
30
|
+
4. [Setup](#setup)
|
|
20
31
|
4. [Documentation](#docs)
|
|
21
32
|
5. [Nfc compatibility](#nfccompatibility)
|
|
22
33
|
6. [Usage Concept](#usageconcept)
|
|
23
34
|
7. [API](#api)
|
|
24
35
|
8. [App demo](#appdemo)
|
|
25
36
|
9. [Learn](#learn)
|
|
37
|
+
10. [Development Example](#development-example)
|
|
26
38
|
|
|
27
39
|
## Installation
|
|
28
40
|
|
|
29
41
|
<a name="installation"></a>
|
|
30
42
|
|
|
31
43
|
```shell
|
|
32
|
-
npm
|
|
44
|
+
npm install react-native-nfc-manager@beta
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This branch documents v4, which is still a prerelease. `@beta` selects the published v4 beta; pin its exact version in your application for reproducible installs. Changes on this branch may be newer than the published beta. An unqualified install currently selects v3 via npm `latest`. Legacy Architecture applications should use `npm install react-native-nfc-manager@3`.
|
|
48
|
+
|
|
49
|
+
See the [v3 → v4 migration guide](https://github.com/revtel/react-native-nfc-manager/blob/v4/docs/MIGRATING_V3_TO_V4.md) before upgrading.
|
|
50
|
+
|
|
51
|
+
### Expo Development Builds
|
|
52
|
+
|
|
53
|
+
`react-native-nfc-manager` contains native code, so it does **not** work in Expo Go. Use an [Expo Development Build](https://docs.expo.dev/develop/development-builds/introduction/) generated locally or by EAS.
|
|
54
|
+
|
|
55
|
+
Install the package and add its config plugin to `app.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"expo": {
|
|
60
|
+
"plugins": [
|
|
61
|
+
[
|
|
62
|
+
"react-native-nfc-manager",
|
|
63
|
+
{
|
|
64
|
+
"nfcPermission": "Allow this app to scan nearby NFC tags",
|
|
65
|
+
"includeNdefEntitlement": true,
|
|
66
|
+
"selectIdentifiers": ["A0000002471001"],
|
|
67
|
+
"systemCodes": ["8008"]
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- `nfcPermission` sets the iOS `NFCReaderUsageDescription` and enables the Android NFC permission. Omit it to use the default description.
|
|
76
|
+
- `nfcPermission: false` is an advanced opt-out: it omits the iOS usage description and blocks the Android permission contributed by the library manifest. NFC cannot be used until the application supplies equivalent native configuration itself.
|
|
77
|
+
- `includeNdefEntitlement` defaults to `true`; set it to `false` to generate only the iOS `TAG` reader-session format.
|
|
78
|
+
- `selectIdentifiers` supplies iOS ISO 7816 application identifiers.
|
|
79
|
+
- `systemCodes` supplies iOS FeliCa system codes.
|
|
80
|
+
|
|
81
|
+
Generate and build the native application after adding or changing the plugin:
|
|
82
|
+
|
|
83
|
+
```shell
|
|
84
|
+
npx expo prebuild
|
|
85
|
+
npx expo run:ios
|
|
86
|
+
# or
|
|
87
|
+
npx expo run:android
|
|
33
88
|
```
|
|
89
|
+
|
|
90
|
+
An EAS Development Build is also a valid deployment path, but a new native build is still required after native dependency or plugin configuration changes. The config plugin generates project files; Apple provisioning must still permit the NFC capability for the selected App ID.
|
|
91
|
+
|
|
92
|
+
Repository maintainers can prepare a packed-package [Expo NFC device smoke app](https://github.com/revtel/react-native-nfc-manager/blob/v4/example-expo/README.md) with `npm run prepare:expo:smoke`. Its build checks do not replace physical-device NFC scans.
|
|
93
|
+
|
|
94
|
+
See the [2026-09-29 Expo physical-device smoke record](https://github.com/revtel/react-native-nfc-manager/blob/v4/docs/EXPO_SMOKE_2026-09-29.md) for tested iPhone/Android flows and remaining validation gaps. The Android smoke app provides a cancellable scan prompt through tag I/O and cleanup.
|
|
95
|
+
|
|
34
96
|
### iOS
|
|
35
97
|
|
|
36
98
|
This library use native-modules, so you will need to do `pod install` for iOS:
|
|
@@ -38,6 +100,9 @@ This library use native-modules, so you will need to do `pod install` for iOS:
|
|
|
38
100
|
```shell
|
|
39
101
|
cd ios && pod install && cd ..
|
|
40
102
|
```
|
|
103
|
+
|
|
104
|
+
Minimum Swift language version for iOS native sources is **Swift 5.7**.
|
|
105
|
+
|
|
41
106
|
### Android
|
|
42
107
|
|
|
43
108
|
It should be properly auto-linked, so you don't need to do anything.
|
|
@@ -50,7 +115,7 @@ It should be properly auto-linked, so you don't need to do anything.
|
|
|
50
115
|
|
|
51
116
|
1. In [apple developer site](https://developer.apple.com/), enable capability for NFC
|
|
52
117
|
|
|
53
|
-

|
|
54
119
|
|
|
55
120
|
2. in Xcode, add `NFCReaderUsageDescription` into your `info.plist`, for example:
|
|
56
121
|
|
|
@@ -92,15 +157,15 @@ An incomplete list of aid's can be found here. [Application identifier](https://
|
|
|
92
157
|
|
|
93
158
|
3. in Xcode's `Signing & Capabilities` tab, make sure `Near Field Communication Tag Reading` capability had been added, like this:
|
|
94
159
|
|
|
95
|
-

|
|
96
161
|
|
|
97
162
|
If this is the first time you toggle the capabilities, the Xcode will generate a `<your-project>.entitlement` file for you:
|
|
98
163
|
|
|
99
|
-

|
|
100
165
|
|
|
101
166
|
4. in Xcode, review the generated entitlement. It should look like this:
|
|
102
167
|
|
|
103
|
-

|
|
104
169
|
|
|
105
170
|
More info on Apple's [doc](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_nfc_readersession_formats?language=objc)
|
|
106
171
|
|
|
@@ -112,27 +177,7 @@ Simple add `uses-permission` into your `AndroidManifest.xml`:
|
|
|
112
177
|
<uses-permission android:name="android.permission.NFC" />
|
|
113
178
|
```
|
|
114
179
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
We start to support Android 12 from `v3.11.1`, and you will need to update `compileSdkVersion` to `31`, otherwise the build will fail:
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
buildscript {
|
|
121
|
-
ext {
|
|
122
|
-
...
|
|
123
|
-
compileSdkVersion = 31
|
|
124
|
-
...
|
|
125
|
-
}
|
|
126
|
-
...
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
The reason for this is because Android puts new limitation on [PendingIntent](https://developer.android.com/reference/android/app/PendingIntent#FLAG_MUTABLE) which says `Starting with Build.VERSION_CODES.S, it will be required to explicitly specify the mutability of PendingIntents`
|
|
131
|
-
|
|
132
|
-
> The original issue is [here](https://github.com/revtel/react-native-nfc-manager/issues/469)
|
|
133
|
-
|
|
134
|
-
If you don't care about **Android 12** for now, you can use **`v3.11.0`** as a short term solution.
|
|
135
|
-
|
|
180
|
+
Use the Android SDK, build tools, NDK, and Java versions required by your React Native version. Do not lower `compileSdkVersion` to an old v3 example value. The development example uses React Native 0.84 with the New Architecture enabled; its toolchain is documented in [example/README.md](https://github.com/revtel/react-native-nfc-manager/blob/v4/example/README.md).
|
|
136
181
|
|
|
137
182
|
## Getting Started
|
|
138
183
|
|
|
@@ -141,32 +186,47 @@ If you don't care about **Android 12** for now, you can use **`v3.11.0`** as a s
|
|
|
141
186
|
The simplest (and most common) use case for this library is to read `NFC` tags containing `NDEF`, which can be achieved via the following codes:
|
|
142
187
|
|
|
143
188
|
```javascript
|
|
144
|
-
import React from 'react';
|
|
189
|
+
import React, {useRef, useState} from 'react';
|
|
145
190
|
import {View, Text, TouchableOpacity, StyleSheet} from 'react-native';
|
|
146
191
|
import NfcManager, {NfcTech} from 'react-native-nfc-manager';
|
|
147
192
|
|
|
148
|
-
// Pre-step, call this before any NFC operations
|
|
149
|
-
NfcManager.start();
|
|
150
|
-
|
|
151
193
|
function App() {
|
|
194
|
+
const scanning = useRef(false);
|
|
195
|
+
const [busy, setBusy] = useState(false);
|
|
196
|
+
|
|
152
197
|
async function readNdef() {
|
|
198
|
+
// A ref also blocks rapid taps before React renders the disabled button.
|
|
199
|
+
if (scanning.current) return;
|
|
200
|
+
scanning.current = true;
|
|
201
|
+
setBusy(true);
|
|
202
|
+
let requestAttempted = false;
|
|
153
203
|
try {
|
|
154
|
-
|
|
204
|
+
await NfcManager.start();
|
|
205
|
+
requestAttempted = true;
|
|
155
206
|
await NfcManager.requestTechnology(NfcTech.Ndef);
|
|
156
|
-
// the resolved tag object will contain `ndefMessage` property
|
|
157
207
|
const tag = await NfcManager.getTag();
|
|
158
|
-
console.warn('
|
|
208
|
+
console.warn('NDEF records', tag?.ndefMessage ?? []);
|
|
159
209
|
} catch (ex) {
|
|
160
|
-
|
|
210
|
+
// Includes initialization, request, cancellation and tag-I/O failures.
|
|
211
|
+
console.warn('NFC scan ended', ex);
|
|
161
212
|
} finally {
|
|
162
|
-
|
|
163
|
-
|
|
213
|
+
try {
|
|
214
|
+
if (requestAttempted) {
|
|
215
|
+
// Await cleanup before permitting a subsequent scan.
|
|
216
|
+
await NfcManager.cancelTechnologyRequest();
|
|
217
|
+
}
|
|
218
|
+
} catch (cleanupError) {
|
|
219
|
+
console.warn('NFC cleanup failed', cleanupError);
|
|
220
|
+
} finally {
|
|
221
|
+
scanning.current = false;
|
|
222
|
+
setBusy(false);
|
|
223
|
+
}
|
|
164
224
|
}
|
|
165
225
|
}
|
|
166
226
|
|
|
167
227
|
return (
|
|
168
228
|
<View style={styles.wrapper}>
|
|
169
|
-
<TouchableOpacity onPress={readNdef}>
|
|
229
|
+
<TouchableOpacity onPress={readNdef} disabled={busy}>
|
|
170
230
|
<Text>Scan a Tag</Text>
|
|
171
231
|
</TouchableOpacity>
|
|
172
232
|
</View>
|
|
@@ -190,7 +250,29 @@ export default App;
|
|
|
190
250
|
|
|
191
251
|
<a name="docs"></a>
|
|
192
252
|
|
|
193
|
-
Check the full documentation that contains `examples`, `faq
|
|
253
|
+
Check the full documentation that contains `examples`, `faq`, and other topics in our [Wiki](https://github.com/revtel/react-native-nfc-manager/wiki). The Expo instructions above are the current v4 integration contract.
|
|
254
|
+
|
|
255
|
+
## Development Example
|
|
256
|
+
|
|
257
|
+
<a name="development-example"></a>
|
|
258
|
+
|
|
259
|
+
For local library development and physical-device NFC testing, use the React Native 0.84 New Architecture example app in [`example/`](https://github.com/revtel/react-native-nfc-manager/tree/v4/example). See [example/README.md](https://github.com/revtel/react-native-nfc-manager/blob/v4/example/README.md).
|
|
260
|
+
|
|
261
|
+
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.
|
|
262
|
+
|
|
263
|
+
### Build (TypeScript)
|
|
264
|
+
|
|
265
|
+
This project now uses a TypeScript build flow and emits distributable JavaScript to `dist/`:
|
|
266
|
+
|
|
267
|
+
```shell
|
|
268
|
+
npm run build
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
For package publishing, `prepack` runs the build automatically.
|
|
272
|
+
|
|
273
|
+
### Routine CI
|
|
274
|
+
|
|
275
|
+
CI on pull requests and `v4` pushes uses Node.js 22 for build, lint, public type checking, root and example mocked tests, package contents, and the RN 0.76.9 / 0.77.3 / 0.84.0 packed Codegen matrix. Separate Android and iOS jobs compile the RN 0.84 New Architecture example when relevant files change; documentation-only changes skip them. Manual CI runs force both builds for release candidates. These are compiler checks, not NFC hardware tests. Packed support-floor and Expo consumer builds remain additional release gates; see [Release Validation](https://github.com/revtel/react-native-nfc-manager/blob/v4/docs/RELEASING.md).
|
|
194
276
|
|
|
195
277
|
## Nfc Compatibility
|
|
196
278
|
|
|
@@ -210,19 +292,21 @@ Check the full documentation that contains `examples`, `faq` and other topics li
|
|
|
210
292
|
| `Iso15693IOS` | ❌ | ✅ |
|
|
211
293
|
| `FelicaIOS` | ❌ | ✅ |
|
|
212
294
|
|
|
295
|
+
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](https://github.com/revtel/react-native-nfc-manager/blob/v4/docs/SUPPORT_POLICY.md) for evidence labels and limitations.
|
|
296
|
+
|
|
213
297
|
## Usage concept
|
|
214
298
|
|
|
215
299
|
<a name="usageconcept"></a>
|
|
216
300
|
|
|
217
301
|
In higher level, there're 4 steps to use this library:
|
|
218
302
|
|
|
219
|
-
0. (
|
|
303
|
+
0. Await `NfcManager.start()` to initialize the native module before requesting a technology. Initialization alone does not start a tag scan.
|
|
220
304
|
|
|
221
305
|
|
|
222
306
|
1. Request your particular NFC technologies through `NfcManager.requestTechnology`. Let's request `Ndef` techonogy.
|
|
223
307
|
|
|
224
308
|
```javascript
|
|
225
|
-
NfcManager.requestTechnology(NfcTech.Ndef);
|
|
309
|
+
await NfcManager.requestTechnology(NfcTech.Ndef);
|
|
226
310
|
```
|
|
227
311
|
|
|
228
312
|
2. Select the proper NFC technology handler, which is implemented as getter in main `NfcManager` object.
|
|
@@ -234,13 +318,13 @@ NfcManager.ndefHandler
|
|
|
234
318
|
3. Call specific methods on the NFC technology handler.
|
|
235
319
|
|
|
236
320
|
```javascript
|
|
237
|
-
NfcManager.ndefHandler.getNdefMessage()
|
|
321
|
+
await NfcManager.ndefHandler.getNdefMessage();
|
|
238
322
|
```
|
|
239
323
|
|
|
240
324
|
4. Clean up your tech registration through:
|
|
241
325
|
|
|
242
326
|
```javascript
|
|
243
|
-
NfcManager.cancelTechnologyRequest()
|
|
327
|
+
await NfcManager.cancelTechnologyRequest();
|
|
244
328
|
```
|
|
245
329
|
|
|
246
330
|
|
|
@@ -248,6 +332,20 @@ NfcManager.cancelTechnologyRequest()
|
|
|
248
332
|
|
|
249
333
|
<a name="api"></a>
|
|
250
334
|
|
|
335
|
+
### Android cached tag metadata
|
|
336
|
+
|
|
337
|
+
Android tag results from discovery and `getTag()` may include these optional, discovery-time fields when the tag supports the corresponding technology:
|
|
338
|
+
|
|
339
|
+
| Technology | Fields |
|
|
340
|
+
| --- | --- |
|
|
341
|
+
| NFC-A | `atqa: number[]`, `sak: number` |
|
|
342
|
+
| NFC-V | `dsfid: number`, `responseFlags: number` |
|
|
343
|
+
| ISO-DEP | `historicalBytes: number[]`, `hiLayerResponse: number[]` |
|
|
344
|
+
|
|
345
|
+
Byte values are unsigned (0–255). An unsupported or unavailable field is omitted; check for its presence before using it. These values come from Android's cached tag discovery data and do not trigger another NFC command. The new NFC-A and NFC-V fields and `hiLayerResponse` are Android-only; `historicalBytes` can also be reported by iOS ISO 7816 tags. Compiler and mock tests do not establish physical-device behavior, so verify each technology with suitable hardware before relying on it in a release.
|
|
346
|
+
|
|
347
|
+
The [2026-09-29 device record](https://github.com/revtel/react-native-nfc-manager/blob/v4/docs/V4_RELEASE_VALIDATION_2026-09-29.md) observed NFC-A `atqa: [68, 0]` and `sak: 0` on Samsung SM-N975U1 / Android 12 with NTAG215. NFC-V and ISO-DEP metadata were not verified on hardware in that session.
|
|
348
|
+
|
|
251
349
|
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.
|
|
252
350
|
|
|
253
351
|
|NFC Technologies | Handlers |
|
|
@@ -272,13 +370,13 @@ The following table shows the handler for each technology, so if you need to use
|
|
|
272
370
|
We have a full featured NFC utility app using this library available for download. The source code is here: [**React Native NFC ReWriter App**](https://github.com/revtel/react-native-nfc-rewriter)
|
|
273
371
|
|
|
274
372
|
<a href='https://apps.apple.com/tw/app/nfc-rewriter/id1551243964' target='_blank'>
|
|
275
|
-
<img alt="react-native-nfc-rewriter" src="
|
|
373
|
+
<img alt="react-native-nfc-rewriter" src="https://raw.githubusercontent.com/revtel/react-native-nfc-manager/v4/images/Apple-App-Store-Icon.png" width="250">
|
|
276
374
|
</a>
|
|
277
375
|
|
|
278
376
|
</br>
|
|
279
377
|
|
|
280
378
|
<a href='https://play.google.com/store/apps/details?id=com.washow.nfcopenrewriter' target='_blank'>
|
|
281
|
-
<img alt="react-native-nfc-rewriter" src="
|
|
379
|
+
<img alt="react-native-nfc-rewriter" src="https://raw.githubusercontent.com/revtel/react-native-nfc-manager/v4/images/google-play-icon.jpeg" width="250">
|
|
282
380
|
</a>
|
|
283
381
|
|
|
284
382
|
## Learn
|
|
@@ -288,4 +386,3 @@ We have a full featured NFC utility app using this library available for downloa
|
|
|
288
386
|
We have published a React Native NFC course with [newline.co](https://www.newline.co/), check it out!
|
|
289
387
|
- Free course (1 hour) about basic NFC setup and concept [here](https://www.youtube.com/watch?v=rAS-DvNUFck)
|
|
290
388
|
- 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)
|
|
291
|
-
|