diff --git a/android/src/main/java/com/reactbolt/sdk/RNBoltReactLibraryModule.java b/android/src/main/java/com/reactbolt/sdk/RNBoltReactLibraryModule.java index 61b1e01..9e5632c 100644 --- a/android/src/main/java/com/reactbolt/sdk/RNBoltReactLibraryModule.java +++ b/android/src/main/java/com/reactbolt/sdk/RNBoltReactLibraryModule.java @@ -46,7 +46,6 @@ public class RNBoltReactLibraryModule extends ReactContextBaseJavaModule { private int REQUEST_PERMISSIONS = 1000; private static final String TAG = "BoltSDK"; private BluetoothSearchResponseListener mBluetoothSearchResponseListener = null; - private Map mapDevices = Collections.synchronizedMap(new HashMap()); ReactApplicationContext context; private boolean enableDebugging = false; @@ -254,15 +253,12 @@ public void discoverDevice() { @Override public void onDeviceFound(BluetoothDevice device) { - synchronized (mapDevices) { - - WritableMap params = Arguments.createMap(); + WritableMap params = Arguments.createMap(); - params.putString("id", device.getAddress()); - params.putString("name", device.getName()); + params.putString("id", device.getAddress()); + params.putString("name", device.getName()); - sendEvent("BoltDeviceFound", params); - } + sendEvent("BoltDeviceFound", params); } }; diff --git a/ios/RNCardConnectReactLibrary.m b/ios/RNCardConnectReactLibrary.m index 7283e24..5bd814b 100644 --- a/ios/RNCardConnectReactLibrary.m +++ b/ios/RNCardConnectReactLibrary.m @@ -6,6 +6,10 @@ #import #import +static NSString *const MESSAGE_CANCELLED_TRANSACTION = @"Canceled transaction."; +static NSString *const MESSAGE_FAILED_CONNECT = @"Failed to connect to device."; +static NSString *const MESSAGE_SWIPE_TAP_INSERT = @"PLEASE SWIPE,\nTAP, OR INSERT"; + @implementation RNCardConnectReactLibrary RCT_EXPORT_MODULE(BoltSDK) @@ -156,7 +160,7 @@ - (void)swiper:(BMSSwiperController *)swiper configurationProgress:(float)progre - (void)swiper:(BMSSwiperController *)swiper displayMessage:(NSString *)message canCancel:(BOOL)cancelable { // special message we will convert into various events - if ([message isEqualToString:@"PLEASE SWIPE,\nTAP, OR INSERT"]) { + if ([message isEqualToString:MESSAGE_SWIPE_TAP_INSERT]) { // device will automatically activate when connecting, so we silently cancel the transaction if (self.isConnecting) { @@ -262,7 +266,7 @@ - (void)swiper:(BMSSwiper *)swiper didFailWithError:(NSError *)error completion: self.restartReaderBlock = completion; // this error will get issued repeatedly while connecting, ignore - if (self.isConnecting && [error.localizedDescription isEqualToString:@"Failed to connect to device."]) { + if (self.isConnecting && [error.localizedDescription isEqualToString:MESSAGE_FAILED_CONNECT]) { // this is where the error for failing to find the serial number surfaces if (error.userInfo) { [self debug:@"user info array"]; @@ -280,7 +284,7 @@ - (void)swiper:(BMSSwiper *)swiper didFailWithError:(NSError *)error completion: // the device will automatically activate after connecting // we cancel this transaction to complete the connection process - if (self.isConnecting && [error.localizedDescription isEqualToString:@"Canceled transaction."]) { + if (self.isConnecting && [error.localizedDescription isEqualToString:MESSAGE_CANCELLED_TRANSACTION]) { [self sendEventWithName:@"BoltOnSwiperConnected" body:@{}]; self.isConnecting = false; return;