Skip to content

Instantly share code, notes, and snippets.

@chrismaddern
Last active March 2, 2019 18:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrismaddern/11198163 to your computer and use it in GitHub Desktop.
Save chrismaddern/11198163 to your computer and use it in GitHub Desktop.
Determine whether bluetooth is enabled on iOS
- (void)startBluetoothStatusMonitoring {
// Horrible formatting, but nicer for blog-width!
self.bluetoothManager = [[CBCentralManager alloc]
initWithDelegate:self
queue:dispatch_get_main_queue()
options:@{CBCentralManagerOptionShowPowerAlertKey: @(NO)}];
}
#pragma mark - CBCentralManagerDelegate
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
if ([central state] == CBCentralManagerStatePoweredOn) {
self.bluetoothEnabled = YES;
}
else {
self.bluetoothEnabled = NO;
}
}
@chrismaddern
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment