Skip to content

Commit

Permalink
Merge pull request #559 from shu223/master
Browse files Browse the repository at this point in the history
Enable to pass a queue identifier on which the events will be dispatched
  • Loading branch information
marcosinigaglia authored Oct 25, 2019
2 parents 7e6ce54 + bcaaf54 commit 101612c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
11 changes: 9 additions & 2 deletions ios/BleManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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;
}

Expand Down

0 comments on commit 101612c

Please sign in to comment.