One*_*nDc 14 bluetooth ios bluetooth-lowenergy
有没有一个API可以告诉我运行我的应用程序的Apple设备(iPad/iPod/iPhone)是否支持蓝牙低功耗(BTLE).
小智 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.";
}
Run Code Online (Sandbox Code Playgroud)
您还需要关注centralManagerDidUpdateState:central代理更新,然后在您的应用中执行相应的操作.
| 归档时间: |
|
| 查看次数: |
6464 次 |
| 最近记录: |