react-native-nfc-manager 4.0.0-beta.5 → 4.0.0-beta.6
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.
|
@@ -788,6 +788,59 @@ class NfcManager extends NativeNfcManagerSpec implements ActivityEventListener,
|
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
790
|
|
|
791
|
+
@ReactMethod
|
|
792
|
+
public void getTimeout(Callback callback) {
|
|
793
|
+
synchronized (this) {
|
|
794
|
+
if (techRequest != null) {
|
|
795
|
+
try {
|
|
796
|
+
String tech = techRequest.getTechType();
|
|
797
|
+
TagTechnology baseTechHandle = techRequest.getTechHandle();
|
|
798
|
+
// TagTechnology is the base class for each tech (ex, NfcA, NfcB, IsoDep ...)
|
|
799
|
+
// but it doesn't provide transceive in its interface, so we need to explicitly cast it
|
|
800
|
+
switch (tech) {
|
|
801
|
+
case "NfcA": {
|
|
802
|
+
NfcA techHandle = (NfcA) baseTechHandle;
|
|
803
|
+
int timeout = techHandle.getTimeout();
|
|
804
|
+
callback.invoke(null, timeout);
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
case "NfcF": {
|
|
808
|
+
NfcF techHandle = (NfcF) baseTechHandle;
|
|
809
|
+
int timeout = techHandle.getTimeout();
|
|
810
|
+
callback.invoke(null, timeout);
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
case "IsoDep": {
|
|
814
|
+
IsoDep techHandle = (IsoDep) baseTechHandle;
|
|
815
|
+
int timeout = techHandle.getTimeout();
|
|
816
|
+
callback.invoke(null, timeout);
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
case "MifareClassic": {
|
|
820
|
+
MifareClassic techHandle = (MifareClassic) baseTechHandle;
|
|
821
|
+
int timeout = techHandle.getTimeout();
|
|
822
|
+
callback.invoke(null, timeout);
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
case "MifareUltralight": {
|
|
826
|
+
MifareUltralight techHandle = (MifareUltralight) baseTechHandle;
|
|
827
|
+
int timeout = techHandle.getTimeout();
|
|
828
|
+
callback.invoke(null, timeout);
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
Log.d(LOG_TAG, "getTimeout not supported");
|
|
833
|
+
callback.invoke(ERR_API_NOT_SUPPORT);
|
|
834
|
+
} catch (Exception ex) {
|
|
835
|
+
Log.d(LOG_TAG, ex.toString());
|
|
836
|
+
callback.invoke(ex.toString());
|
|
837
|
+
}
|
|
838
|
+
} else {
|
|
839
|
+
callback.invoke(ERR_NO_TECH_REQ);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
|
|
791
844
|
@ReactMethod
|
|
792
845
|
public void connect(ReadableArray techs, Callback callback){
|
|
793
846
|
synchronized(this) {
|
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": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.6",
|
|
4
4
|
"description": "A NFC module for react native.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"typescript": "^4.1.3"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@expo/config-plugins": "
|
|
67
|
+
"@expo/config-plugins": "*"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|
|
70
70
|
"@expo/config-plugins": {
|
|
@@ -57,6 +57,7 @@ export interface Spec extends TurboModule {
|
|
|
57
57
|
goToNfcSetting(callback: (err?: string) => void): void;
|
|
58
58
|
getLaunchTagEvent(callback: (err?: string, tag?: Object) => void): void;
|
|
59
59
|
setTimeout(timeout: number, callback: (err?: string, tag?: Object) => void): void;
|
|
60
|
+
getTimeout(callback: (err?: string, timeout?: number) => void): void;
|
|
60
61
|
connect(techs: string[], callback: (err?: string) => void): void;
|
|
61
62
|
close(callback: (err?: string) => void): void;
|
|
62
63
|
transceive(bytes: number[], callback: (err?: string, bytes?: number[]) => void): void;
|
package/src/NfcManager.js
CHANGED
package/src/NfcManagerAndroid.js
CHANGED
|
@@ -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'));
|