14

Is there an API via which I can tell if the Apple device (iPad/iPod/iPhone) that my App is running on supports Bluetooth Low Energy (BTLE).

3 Answers 3

14

Assuming you have an iOS5 or iOS6 device and that you have a CBCentralManager object, you can check its CBCentralManagerState with the following:

switch ([_manager state])
{
    case CBCentralManagerStateUnsupported:
        state = @"This device does not support Bluetooth Low Energy.";
        break;
    case CBCentralManagerStateUnauthorized:
        state = @"This app is not authorized to use Bluetooth Low Energy.";
        break;
    case CBCentralManagerStatePoweredOff:
        state = @"Bluetooth on this device is currently powered off.";
        break;
    case CBCentralManagerStateResetting:
        state = @"The BLE Manager is resetting; a state update is pending.";
        break;
    case CBCentralManagerStatePoweredOn:
        state = @"Bluetooth LE is turned on and ready for communication.";
        break;
    case CBCentralManagerStateUnknown:
        state = @"The state of the BLE Manager is unknown.";
        break;
    default:
        state = @"The state of the BLE Manager is unknown.";

}

You'll want to watch for centralManagerDidUpdateState:central delegate updates as well, then take the appropriate action in your app.

1
  • If I get CBCentralManagerStatePoweredOn or CBCentralManagerStatePoweredOff is that a guarantee that BLE is supported?
    – Ky -
    Commented Jan 25, 2016 at 22:48
4

Another option is to check whether the device supports iBeacons. This is because the device must support Bluetooth LE (i.e. Bluetooth 4) in order to find an iBeacon. Just import CoreLocation and use the following:

Swift:

if (CLLocationManager.isMonitoringAvailable(for: CLBeaconRegion.self)){
    print("Bluetooth LE is supported")
}

Objective C:

if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]]){
    NSLog(@"Bluetooth LE is supported");
}
1
  • This worked for me. This way you can have a simple getter, rather than trying to do some more complicated pattern using the state. Commented Jul 25, 2016 at 15:24
1

Look for CoreBluetooth.framework... CBCentralManagerStateUnsupported, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.