@scrumble-nl/react-native-honeywell-scanner 1.0.64 → 1.0.66

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,15 +80,33 @@ public class HoneywellScannerModule extends ReactContextBaseJavaModule implement
79
80
  /*******************************/
80
81
 
81
82
  @ReactMethod
82
- public void startReader(Callback callBack) {
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
- manager.addBarcodeDeviceListener(BarcodeDeviceListener listener) {
88
- listener.onBarcodeDeviceConnectionEvent(BarcodeDeviceConnectionEvent event) {
89
- callBack.invoke(event.getBarcodeReaderInfo().getName());
90
- }
88
+
89
+ if (manager != null) {
90
+ promise.resolve(true);
91
+
92
+ manager.addBarcodeDeviceListener(new BarcodeDeviceListener() {
93
+ @Override
94
+ public void onBarcodeDeviceConnectionEvent(BarcodeDeviceConnectionEvent event) {
95
+ if (event.getConnectionStatus() == manager.BARCODE_DEVICE_CONNECTED) {
96
+ BarcodeReaderInfo readerInfo = event.getBarcodeReaderInfo();
97
+
98
+ WritableMap params = Arguments.createMap();
99
+ params.putString("data", readerInfo.getName());
100
+ sendEvent(DEVICE_CHANGE, params);
101
+ }
102
+ }
103
+ });
104
+
105
+
106
+ // manager.addBarcodeDeviceListener(BarcodeDeviceListener listener) {
107
+ // listener.onBarcodeDeviceConnectionEvent(BarcodeDeviceConnectionEvent event) {
108
+ // }
109
+ // }
91
110
  }
92
111
  }
93
112
  });
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scrumble-nl/react-native-honeywell-scanner",
3
3
  "title": "React Native Honeywell Scanner-v2",
4
- "version": "1.0.64",
4
+ "version": "1.0.66",
5
5
  "description": "Bridge to use the Honeywell scanner",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",