是否有一个 API,我可以通过它判断我的应用程序运行的 Apple 设备(iPad/iPod/iPhone)是否支持蓝牙低功耗(BTLE)。
问问题
7134 次
3 回答
14
假设您有一个 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
还需要关注委托更新,然后在您的应用程序中采取适当的操作。
于 2013-02-10T12:18:36.613 回答
4
另一种选择是检查设备是否支持 iBeacons。这是因为设备必须支持蓝牙 LE(即蓝牙 4)才能找到 iBeacon。只需导入 CoreLocation 并使用以下内容:
迅速:
if (CLLocationManager.isMonitoringAvailable(for: CLBeaconRegion.self)){
print("Bluetooth LE is supported")
}
目标 C:
if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]]){
NSLog(@"Bluetooth LE is supported");
}
于 2015-03-16T13:59:46.387 回答
1
寻找CoreBluetooth.framework ... CBCentralManagerStateUnsupported等。
于 2012-11-27T14:24:25.100 回答