Есть ли API, через который я могу узнать, поддерживает ли устройство Apple (iPad/iPod/iPhone) мое приложение на Bluetooth Low Energy (BTLE).
Как я могу определить, поддерживает ли мое устройство Apple Bluetooth Low Energy
Ответ 1
Предполагая, что у вас есть устройство iOS5 или iOS6, и у вас есть объект CBCentralManager, вы можете проверить его CBCentralManagerState следующим образом:
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.";
}
Вы также захотите посмотреть обновления делегата centralManagerDidUpdateState:central
, а затем предпримите соответствующие действия в своем приложении.
Ответ 2
Другой вариант - проверить, поддерживает ли устройство iBeacons. Это связано с тем, что устройство должно поддерживать Bluetooth LE (то есть Bluetooth 4), чтобы найти iBeacon. Просто импортируйте CoreLocation и используйте следующее:
Swift:
if (CLLocationManager.isMonitoringAvailable(for: CLBeaconRegion.self)){
print("Bluetooth LE is supported")
}
Цель C:
if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]]){
NSLog(@"Bluetooth LE is supported");
}
Ответ 3
Ищите CoreBluetooth.framework... CBCentralManagerStateUnsupported и т.д.