Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect if my apple device supports Bluetooth Low Energy

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).

like image 894
OneGuyInDc Avatar asked Nov 27 '12 13:11

OneGuyInDc


People also ask

Does iPhone have Bluetooth Low Energy?

There are two types of Bluetooth in Apple devices, Bluetooth Classic and Bluetooth Low Energy (BLE).

How do I know if my device supports BLE?

This allows Android apps to communicate with BLE devices that have low power requirements, such as proximity sensors, heart rate monitors, fitness devices, and so on. To check if your device support Bluetooth Low Energy programmically, check (getPackageManager(). hasSystemFeature(PackageManager. FEATURE_BLUETOOTH_LE)).

Does Apple support Bluetooth LE?

Apple supports the use of Bluetooth Low Energy (LE) hearing aids. Apps don't have control over routing to these devices. Instead, the system automatically decides when routing to Bluetooth LE is appropriate.


2 Answers

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.

like image 142
Bob Kressin Avatar answered Oct 03 '22 18:10

Bob Kressin


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");
}
like image 29
Ian Avatar answered Oct 03 '22 19:10

Ian