如何检测我的苹果设备是否支持低功耗蓝牙

如何检测我的苹果设备是否支持低功耗蓝牙

本文介绍了如何检测我的苹果设备是否支持低功耗蓝牙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有 API 可让我判断运行我的应用程序的 Apple 设备(iPad/iPod/iPhone)是否支持低功耗蓝牙 (BTLE).

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

推荐答案

假设你有一个 iOS5 或 iOS6 设备并且你有一个 CBCentralManager 对象,你可以使用以下内容检查它的 CBCentralManagerState:

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.";

}

您还需要注意 centralManagerDidUpdateState:central 委托更新,然后在您的应用中采取适当的操作.

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

这篇关于如何检测我的苹果设备是否支持低功耗蓝牙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 12:49