我怎样才能检测是否我的苹果设备支持蓝牙低耗能 [英] How can I detect if my apple device supports Bluetooth Low Energy

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

问题描述

有没有一个API,通过它我可以告诉大家,如果苹果的设备(新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:中央委托更新为好,然后采取适当的行动,您的应用程序

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆