react-native-nfc-manager 3.16.2 → 3.17.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 CHANGED
@@ -12,6 +12,11 @@ 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 (latest release is `v3.16.3`).
18
+ - `v4` supports new architecture (still in beta, latest release is `v4.0.0-beta.4`) .
19
+
15
20
  ## Table of Contents
16
21
 
17
22
  1. [Installation](#installation)
@@ -743,6 +743,59 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
743
743
  }
744
744
  }
745
745
 
746
+ @ReactMethod
747
+ public void getTimeout(Callback callback) {
748
+ synchronized (this) {
749
+ if (techRequest != null) {
750
+ try {
751
+ String tech = techRequest.getTechType();
752
+ TagTechnology baseTechHandle = techRequest.getTechHandle();
753
+ // TagTechnology is the base class for each tech (ex, NfcA, NfcB, IsoDep ...)
754
+ // but it doesn't provide transceive in its interface, so we need to explicitly cast it
755
+ switch (tech) {
756
+ case "NfcA": {
757
+ NfcA techHandle = (NfcA) baseTechHandle;
758
+ int timeout = techHandle.getTimeout();
759
+ callback.invoke(null, timeout);
760
+ return;
761
+ }
762
+ case "NfcF": {
763
+ NfcF techHandle = (NfcF) baseTechHandle;
764
+ int timeout = techHandle.getTimeout();
765
+ callback.invoke(null, timeout);
766
+ return;
767
+ }
768
+ case "IsoDep": {
769
+ IsoDep techHandle = (IsoDep) baseTechHandle;
770
+ int timeout = techHandle.getTimeout();
771
+ callback.invoke(null, timeout);
772
+ return;
773
+ }
774
+ case "MifareClassic": {
775
+ MifareClassic techHandle = (MifareClassic) baseTechHandle;
776
+ int timeout = techHandle.getTimeout();
777
+ callback.invoke(null, timeout);
778
+ return;
779
+ }
780
+ case "MifareUltralight": {
781
+ MifareUltralight techHandle = (MifareUltralight) baseTechHandle;
782
+ int timeout = techHandle.getTimeout();
783
+ callback.invoke(null, timeout);
784
+ return;
785
+ }
786
+ }
787
+ Log.d(LOG_TAG, "getTimeout not supported");
788
+ callback.invoke(ERR_API_NOT_SUPPORT);
789
+ } catch (Exception ex) {
790
+ Log.d(LOG_TAG, ex.toString());
791
+ callback.invoke(ex.toString());
792
+ }
793
+ } else {
794
+ callback.invoke(ERR_NO_TECH_REQ);
795
+ }
796
+ }
797
+ }
798
+
746
799
  @ReactMethod
747
800
  public void connect(ReadableArray techs, Callback callback){
748
801
  synchronized(this) {
@@ -1151,9 +1204,9 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
1151
1204
  try {
1152
1205
  if (isReaderModeEnabled) {
1153
1206
  if (enable) {
1154
- Log.i(LOG_TAG, "enableReaderMode: " + readerModeFlags);
1207
+ Log.i(LOG_TAG, String.format("enableReaderMode, flags: %d, delay: %d ms", readerModeFlags, readerModeDelay));
1155
1208
  Bundle readerModeExtras = new Bundle();
1156
- readerModeExtras.putInt(NfcAdapter.EXTRA_READER_PRESENCE_CHECK_DELAY, readerModeDelay * 1000);
1209
+ readerModeExtras.putInt(NfcAdapter.EXTRA_READER_PRESENCE_CHECK_DELAY, readerModeDelay);
1157
1210
  nfcAdapter.enableReaderMode(currentActivity, new NfcAdapter.ReaderCallback() {
1158
1211
  @Override
1159
1212
  public void onTagDiscovered(Tag tag) {
package/index.d.ts CHANGED
@@ -284,6 +284,7 @@ declare module 'react-native-nfc-manager' {
284
284
  transceive(bytes: number[]): Promise<number[]>;
285
285
  getMaxTransceiveLength(): Promise<number>;
286
286
  setTimeout(timeout: number): Promise<void>;
287
+ getTimeout(): Promise<number|void>;
287
288
  connect: (techs: NfcTech[]) => Promise<void>;
288
289
  close: () => Promise<void>;
289
290
  mifareClassicHandlerAndroid: MifareClassicHandlerAndroid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nfc-manager",
3
- "version": "3.16.2",
3
+ "version": "3.17.0",
4
4
  "description": "A NFC module for react native.",
5
5
  "main": "src/index.js",
6
6
  "repository": {
package/src/NfcManager.js CHANGED
@@ -42,7 +42,7 @@ const DEFAULT_REGISTER_TAG_EVENT_OPTIONS = {
42
42
  invalidateAfterFirstRead: false,
43
43
  isReaderModeEnabled: false,
44
44
  readerModeFlags: 0,
45
- readerModeDelay: 10,
45
+ readerModeDelay: 250,
46
46
  };
47
47
 
48
48
  function NotImpl() {
@@ -106,6 +106,8 @@ class NfcManagerBase {
106
106
 
107
107
  setAlertMessage = DoNothing;
108
108
 
109
+ getTimeout = DoNothing;
110
+
109
111
  async writeNdefMessage(bytes, options = {}) {
110
112
  return handleNativeException(callNative('writeNdefMessage', [bytes, options]));
111
113
  }
@@ -84,6 +84,8 @@ class NfcManagerAndroid extends NfcManagerBase {
84
84
  setTimeout = (timeout) =>
85
85
  handleNativeException(callNative('setTimeout', [timeout]));
86
86
 
87
+ getTimeout = () => handleNativeException(callNative('getTimeout'));
88
+
87
89
  connect = (techs) => handleNativeException(callNative('connect', [techs]));
88
90
 
89
91
  close = () => handleNativeException(callNative('close'));