react-native-nfc-manager 3.11.0 → 3.11.1

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 CHANGED
@@ -8,7 +8,7 @@ Bring NFC feature to React Native. Inspired by [phonegap-nfc](https://github.com
8
8
 
9
9
  Contributions are welcome!
10
10
 
11
- > We also have a slack channel, you're welcome to chat with us for any issue or idea! [join us here](https://join.slack.com/t/reactnativenf-ewh2625/shared_invite/zt-puz9y22v-3rkORO6_zQe4FmaWm6ku_w)
11
+ Made with ❤️ by [whitedogg13](https://github.com/whitedogg13) and [revteltech](https://github.com/revtel)
12
12
 
13
13
  ## Install
14
14
 
@@ -41,15 +41,14 @@ We have a full featured NFC utility app available for download.
41
41
  <a href='https://apps.apple.com/tw/app/nfc-rewriter/id1551243964' target='_blank'>
42
42
  <img alt="react-native-nfc-rewriter" src="./images/Apple-App-Store-Icon.png" width="250">
43
43
  </a>
44
- <br/>
45
44
 
46
- It also open sourced in this repo: [React Native NFC ReWriter App](https://github.com/revtel/react-native-nfc-rewriter)
47
-
48
- ### [Bonus] Reconnect.js
45
+ </br>
49
46
 
50
- Super useful library to help you share states between `sibling` and `nested` React components.
47
+ <a href='https://play.google.com/store/apps/details?id=com.washow.nfcopenrewriter' target='_blank'>
48
+ <img alt="react-native-nfc-rewriter" src="./images/google-play-icon.jpeg" width="250">
49
+ </a>
51
50
 
52
- [Check it out!](https://github.com/revtel/reconnect.js)
51
+ It also open sourced in this repo: [React Native NFC ReWriter App](https://github.com/revtel/react-native-nfc-rewriter)
53
52
 
54
53
  ## Basic Usage
55
54
 
@@ -163,41 +162,49 @@ async function initNfc() {
163
162
 
164
163
  async function readMifare() {
165
164
  try {
166
- // 0. Request Mifare technology
167
- let reqMifare = await NfcManager.requestTechnology(NfcTech.MifareUltralight);
168
- if (reqMifare !== 'MifareUltralight') {
169
- throw new Error('[NFC Read] [ERR] Mifare technology could not be requested');
170
- };
171
-
172
- // 1. Get NFC Tag information
173
- const nfcTag = await NfcManager.getTag()
174
- console.log('[NFC Read] [INFO] Tag: ', nfcTag);
175
-
176
- // 2. Read pages
177
- const readLength = 60;
178
- let mifarePages = [];
179
- const mifarePagesRead = await Promise.all([...Array(readLength).keys()].map(async (_, i) => {
180
- const pageOffset = i * 4; // 4 Pages are read at once, so offset should be in steps with length 4
181
- let pages = await NfcManager.mifareUltralightHandlerAndroid.mifareUltralightReadPages(pageOffset);
182
- mifarePages.push(pages);
183
- console.log(`[NFC Read] [INFO] Mifare Page: ${pageOffset}`, pages);
184
- //await wait(500); // If Mifare Chip is to slow
185
- }));
186
-
187
- // 3. Success
188
- console.log('[NFC Read] [INFO] Success reading Mifare');
189
-
190
- // 4. Cleanup
191
- _cleanup();
165
+ // 0. Request Mifare technology
166
+ let reqMifare = await NfcManager.requestTechnology(
167
+ NfcTech.MifareUltralight,
168
+ );
169
+ if (reqMifare !== 'MifareUltralight') {
170
+ throw new Error(
171
+ '[NFC Read] [ERR] Mifare technology could not be requested',
172
+ );
173
+ }
174
+
175
+ // 1. Get NFC Tag information
176
+ const nfcTag = await NfcManager.getTag();
177
+ console.log('[NFC Read] [INFO] Tag: ', nfcTag);
178
+
179
+ // 2. Read pages
180
+ const readLength = 60;
181
+ let mifarePages = [];
182
+ const mifarePagesRead = await Promise.all(
183
+ [...Array(readLength).keys()].map(async (_, i) => {
184
+ const pageOffset = i * 4; // 4 Pages are read at once, so offset should be in steps with length 4
185
+ let pages = await NfcManager.mifareUltralightHandlerAndroid.mifareUltralightReadPages(
186
+ pageOffset,
187
+ );
188
+ mifarePages.push(pages);
189
+ console.log(`[NFC Read] [INFO] Mifare Page: ${pageOffset}`, pages);
190
+ //await wait(500); // If Mifare Chip is to slow
191
+ }),
192
+ );
193
+
194
+ // 3. Success
195
+ console.log('[NFC Read] [INFO] Success reading Mifare');
196
+
197
+ // 4. Cleanup
198
+ _cleanup();
192
199
  } catch (ex) {
193
- console.warn('[NFC Read] [ERR] Failed Reading Mifare: ', ex);
194
- _cleanup();
200
+ console.warn('[NFC Read] [ERR] Failed Reading Mifare: ', ex);
201
+ _cleanup();
195
202
  }
196
- };
203
+ }
197
204
 
198
205
  function _cleanup() {
199
- NfcManager.cancelTechnologyRequest().catch(() => 0);
200
- };
206
+ NfcManager.cancelTechnologyRequest().catch(() => 0);
207
+ }
201
208
  ```
202
209
 
203
210
  To see more examples, please see [React Native NFC ReWriter App](https://github.com/revtel/react-native-nfc-rewriter)
@@ -252,3 +259,4 @@ The plugin provides props for extra customization. Every time you change the pro
252
259
  }
253
260
  }
254
261
  ```
262
+
@@ -1064,7 +1064,12 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
1064
1064
  Activity activity = getCurrentActivity();
1065
1065
  Intent intent = new Intent(activity, activity.getClass());
1066
1066
  intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
1067
- return PendingIntent.getActivity(activity, 0, intent, 0);
1067
+
1068
+ int flag = 0;
1069
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
1070
+ flag = PendingIntent.FLAG_MUTABLE;
1071
+ }
1072
+ return PendingIntent.getActivity(activity, 0, intent, flag);
1068
1073
  }
1069
1074
 
1070
1075
  private IntentFilter[] getIntentFilters() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nfc-manager",
3
- "version": "3.11.0",
3
+ "version": "3.11.1",
4
4
  "description": "A NFC module for react native.",
5
5
  "main": "src/index.js",
6
6
  "repository": {