@scrumble-nl/react-native-honeywell-scanner 1.0.64 → 1.0.65
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.
|
@@ -32,6 +32,7 @@ public class HoneywellScannerModule extends ReactContextBaseJavaModule implement
|
|
|
32
32
|
private String connectedDevice = "dcs.scanner.imager";
|
|
33
33
|
private static final String BARCODE_READ_SUCCESS = "barcodeReadSuccess";
|
|
34
34
|
private static final String BARCODE_READ_FAIL = "barcodeReadFail";
|
|
35
|
+
private static final String DEVICE_CHANGE = "deviceChange";
|
|
35
36
|
|
|
36
37
|
public HoneywellScannerModule(ReactApplicationContext reactContext) {
|
|
37
38
|
super(reactContext);
|
|
@@ -79,14 +80,24 @@ public class HoneywellScannerModule extends ReactContextBaseJavaModule implement
|
|
|
79
80
|
/*******************************/
|
|
80
81
|
|
|
81
82
|
@ReactMethod
|
|
82
|
-
public void startReader(
|
|
83
|
+
public void startReader(final Promise promise) {
|
|
83
84
|
AidcManager.create(reactContext, new CreatedCallback() {
|
|
84
85
|
@Override
|
|
85
86
|
public void onCreated(AidcManager aidcManager) {
|
|
86
87
|
manager = aidcManager;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
|
|
89
|
+
if (manager != null) {
|
|
90
|
+
promise.resolve(true);
|
|
91
|
+
manager.addBarcodeDeviceListener(BarcodeDeviceListener listener) {
|
|
92
|
+
listener.onBarcodeDeviceConnectionEvent(BarcodeDeviceConnectionEvent event) {
|
|
93
|
+
if (event.getConnectionStatus() == manager.BARCODE_DEVICE_CONNECTED) {
|
|
94
|
+
BarcodeReaderInfo readerInfo = event.getBarcodeReaderInfo();
|
|
95
|
+
|
|
96
|
+
WritableMap params = Arguments.createMap();
|
|
97
|
+
params.putString("data", readerInfo.getName());
|
|
98
|
+
sendEvent(DEVICE_CHANGE, params);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
90
101
|
}
|
|
91
102
|
}
|
|
92
103
|
}
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const { HoneywellScanner } = react_native_1.NativeModules;
|
|
|
10
10
|
const barcodeReaderEmitter = new react_native_1.NativeEventEmitter(HoneywellScanner);
|
|
11
11
|
var subscriptionBarcodeReadSuccess = null;
|
|
12
12
|
var subscriptionBarcodeReadFail = null;
|
|
13
|
+
var subscriptionDeviceChange = null;
|
|
13
14
|
HoneywellScanner.onBarcodeReadSuccess = (handler) => {
|
|
14
15
|
subscriptionBarcodeReadSuccess === null || subscriptionBarcodeReadSuccess === void 0 ? void 0 : subscriptionBarcodeReadSuccess.remove();
|
|
15
16
|
subscriptionBarcodeReadSuccess = null;
|
|
@@ -20,6 +21,11 @@ HoneywellScanner.onBarcodeReadFail = (handler) => {
|
|
|
20
21
|
subscriptionBarcodeReadFail = null;
|
|
21
22
|
subscriptionBarcodeReadFail = barcodeReaderEmitter.addListener(HoneywellScanner.BARCODE_READ_FAIL, handler);
|
|
22
23
|
};
|
|
24
|
+
HoneywellScanner.onDeviceChange = (handler) => {
|
|
25
|
+
subscriptionDeviceChange === null || subscriptionDeviceChange === void 0 ? void 0 : subscriptionDeviceChange.remove();
|
|
26
|
+
subscriptionDeviceChange = null;
|
|
27
|
+
subscriptionDeviceChange = barcodeReaderEmitter.addListener(HoneywellScanner.DEVICE_CHANGE, handler);
|
|
28
|
+
};
|
|
23
29
|
/**
|
|
24
30
|
* Stop listening for event
|
|
25
31
|
* @param {String} eventName Name of event one of barcodeReadSuccess, barcodeReadFail
|
|
@@ -31,4 +37,7 @@ HoneywellScanner.offBarcodeReadSuccess = () => {
|
|
|
31
37
|
HoneywellScanner.offBarcodeReadFail = () => {
|
|
32
38
|
subscriptionBarcodeReadFail === null || subscriptionBarcodeReadFail === void 0 ? void 0 : subscriptionBarcodeReadFail.remove();
|
|
33
39
|
};
|
|
40
|
+
HoneywellScanner.offDeviceChange = () => {
|
|
41
|
+
subscriptionDeviceChange === null || subscriptionDeviceChange === void 0 ? void 0 : subscriptionDeviceChange.remove();
|
|
42
|
+
};
|
|
34
43
|
exports.default = HoneywellScanner;
|
package/package.json
CHANGED