react-native-nfc-manager 3.11.4 → 3.11.5

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.
Files changed (3) hide show
  1. package/README.md +12 -10
  2. package/app.plugin.js +8 -0
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -69,7 +69,7 @@ We have a full featured NFC utility app using this library available for downloa
69
69
 
70
70
  It also open sourced in this repo: [React Native NFC ReWriter App](https://github.com/revtel/react-native-nfc-rewriter)
71
71
 
72
- ## Usage
72
+ ## Usage
73
73
 
74
74
  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:
75
75
 
@@ -118,6 +118,7 @@ export default App;
118
118
  ```
119
119
 
120
120
  Pleaes notice when running above codes, iOS and Android has different behaviors:
121
+
121
122
  - iOS will pop up a system scanning UI
122
123
  - Android provides **NO** system scanning UI
123
124
 
@@ -130,7 +131,7 @@ There's an alterntaive style to scan NFC tags through `NfcManager.registerTagEve
130
131
  ```javascript
131
132
  import NfcManager, {NfcTech} from 'react-native-nfc-manager';
132
133
 
133
- // The following function resolves to a NFC Tag object using old event listener approach.
134
+ // The following function resolves to a NFC Tag object using old event listener approach.
134
135
  // You can call it like this:
135
136
  // `const nfcTag = await listenToNfcEventOnce()`
136
137
 
@@ -140,10 +141,10 @@ function listenToNfcEventOnce() {
140
141
  NfcManager.setEventListener(NfcEvents.SessionClosed, null);
141
142
  };
142
143
 
143
- return new Promise(resolve => {
144
+ return new Promise((resolve) => {
144
145
  let tagFound = null;
145
146
 
146
- NfcManager.setEventListener(NfcEvents.DiscoverTag, tag => {
147
+ NfcManager.setEventListener(NfcEvents.DiscoverTag, (tag) => {
147
148
  tagFound = tag;
148
149
  resolve(tagFound);
149
150
  NfcManager.unregisterTagEvent();
@@ -168,6 +169,7 @@ As you can see, the above approach is more verbose and hard-to-read, so we recom
168
169
  In higher level, there're 4 steps to use this library:
169
170
 
170
171
  1. request your particular NFC technologies through `NfcManager.requestTechnology`, for example:
172
+
171
173
  - `Ndef`
172
174
  - `NfcA`
173
175
  - `NfcB` (Android-only)
@@ -181,6 +183,7 @@ In higher level, there're 4 steps to use this library:
181
183
  - `FelicaIOS` (ios-only)
182
184
 
183
185
  2. select the proper NFC technology handler, which is implemented as getter in main `NfcManager` object, for example:
186
+
184
187
  - `ndefHandler` (for `Ndef` tech)
185
188
  - `nfcAHandler` (for `NfcA` tech)
186
189
  - `isoDepHandler` (for `IsoDep` tech)
@@ -189,7 +192,7 @@ In higher level, there're 4 steps to use this library:
189
192
  - `mifareUltralightHandlerAndroid` (for `mifareUltralight` tech)
190
193
  - ... and so on
191
194
 
192
- 3. call specific methods on the NFC technology handler (for example `NfcManager.ndefHandler.writeNdefMessage`). To view all available methods for some tech handler, check out the [API List]((index.d.ts))
195
+ 3. call specific methods on the NFC technology handler (for example `NfcManager.ndefHandler.writeNdefMessage`). To view all available methods for some tech handler, check out the [API List](index.d.ts)
193
196
 
194
197
  4. clean up your tech registration through `NfcManager.cancelTechnology`
195
198
 
@@ -210,8 +213,7 @@ async function writeNdef({type, value}) {
210
213
  const bytes = Ndef.encodeMessage([Ndef.textRecord('Hello NFC')]);
211
214
 
212
215
  if (bytes) {
213
- await NfcManager
214
- .ndefHandler // STEP 2
216
+ await NfcManager.ndefHandler // STEP 2
215
217
  .writeNdefMessage(bytes); // STEP 3
216
218
  result = true;
217
219
  }
@@ -243,8 +245,7 @@ async function readMifare() {
243
245
  const readLength = 60;
244
246
  const mifarePagesRead = await Promise.all(
245
247
  [...Array(readLength).keys()].map(async (_, i) => {
246
- const pages = await NfcManager
247
- .mifareUltralightHandlerAndroid // STEP 2
248
+ const pages = await NfcManager.mifareUltralightHandlerAndroid // STEP 2
248
249
  .mifareUltralightReadPages(i * 4); // STEP 3
249
250
  mifarePages.push(pages);
250
251
  }),
@@ -286,6 +287,8 @@ After installing this npm package, add the [config plugin](https://docs.expo.io/
286
287
 
287
288
  Next, rebuild your app as described in the ["Adding custom native code"](https://docs.expo.io/workflow/customizing/) guide.
288
289
 
290
+ > Notice: This Config Plugin will ensure the minimum Android SDK version is 31.
291
+
289
292
  #### Props
290
293
 
291
294
  The plugin provides props for extra customization. Every time you change the props or plugins, you'll need to rebuild (and `prebuild`) the native app. If no extra properties are added, defaults will be used.
@@ -312,4 +315,3 @@ The plugin provides props for extra customization. Every time you change the pro
312
315
  }
313
316
  }
314
317
  ```
315
-
package/app.plugin.js CHANGED
@@ -85,6 +85,14 @@ function withNfc(config, props = {}) {
85
85
  config = withIosNfcEntitlement(config);
86
86
  config = withIosNfcSelectIdentifiers(config, {selectIdentifiers});
87
87
  config = withIosNfcSystemCodes(config, {systemCodes});
88
+
89
+ // We start to support Android 12 from v3.11.1, and you will need to update compileSdkVersion to 31,
90
+ // otherwise the build will fail:
91
+ config = AndroidConfig.Version.withBuildScriptExtMinimumVersion(config, {
92
+ name: 'compileSdkVersion',
93
+ minVersion: 31,
94
+ });
95
+
88
96
  if (nfcPermission !== false) {
89
97
  config = withIosPermission(config, props);
90
98
  config = AndroidConfig.Permissions.withPermissions(config, [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nfc-manager",
3
- "version": "3.11.4",
3
+ "version": "3.11.5",
4
4
  "description": "A NFC module for react native.",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -62,7 +62,7 @@
62
62
  "typescript": "^4.1.3"
63
63
  },
64
64
  "dependencies": {
65
- "@expo/config-plugins": "^3.0.6"
65
+ "@expo/config-plugins": "^4.0.16"
66
66
  },
67
67
  "scripts": {
68
68
  "lint": "eslint .",