From 419d8fb1fdbad8376fab6f32aa8afb3b57982a1c Mon Sep 17 00:00:00 2001 From: shu223 Date: Thu, 24 Oct 2019 12:59:56 +0900 Subject: [PATCH 1/2] Enable to pass a queue identifier on which the events will be dispatched. --- ios/BleManager.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ios/BleManager.m b/ios/BleManager.m index 56bfa4a6..d2e278fe 100644 --- a/ios/BleManager.m +++ b/ios/BleManager.m @@ -287,6 +287,13 @@ -(int) compareCBUUID:(CBUUID *) UUID1 UUID2:(CBUUID *)UUID2 forKey:CBCentralManagerOptionShowPowerAlertKey]; } + dispatch_queue_t queue; + if ([[options allKeys] containsObject:@"queueIdentifierKey"]) { + queue = dispatch_queue_create([[options valueForKey:@"queueIdentifierKey"] UTF8String], DISPATCH_QUEUE_SERIAL); + } else { + queue = dispatch_get_main_queue(); + } + if ([[options allKeys] containsObject:@"restoreIdentifierKey"]) { [initOptions setObject:[options valueForKey:@"restoreIdentifierKey"] @@ -296,11 +303,11 @@ -(int) compareCBUUID:(CBUUID *) UUID1 UUID2:(CBUUID *)UUID2 manager = _sharedManager; manager.delegate = self; } else { - manager = [[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue() options:initOptions]; + manager = [[CBCentralManager alloc] initWithDelegate:self queue:queue options:initOptions]; _sharedManager = manager; } } else { - manager = [[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue() options:initOptions]; + manager = [[CBCentralManager alloc] initWithDelegate:self queue:queue options:initOptions]; _sharedManager = manager; } From bcaaf54d80c5ffdbfe4409eb19a041f473a7f121 Mon Sep 17 00:00:00 2001 From: shu223 Date: Fri, 25 Oct 2019 19:16:35 +0900 Subject: [PATCH 2/2] Update README about queueIdentifierKey --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 73478674..d4e90c4a 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ __Arguments__ The parameter is optional the configuration keys are: - `showAlert` - `Boolean` - [iOS only] Show or hide the alert if the bluetooth is turned off during initialization - `restoreIdentifierKey` - `String` - [iOS only] Unique key to use for CoreBluetooth state restoration +- `queueIdentifierKey` - `String` - [iOS only] Unique key to use for a queue identifier on which CoreBluetooth events will be dispatched - `forceLegacy` - `Boolean` - [Android only] Force to use the LegacyScanManager __Examples__