14

アプリが実行されているAppleデバイス(iPad / iPod / iPhone)がBluetooth Low Energy(BTLE)をサポートしているかどうかを確認できるAPIはありますか?

4

3 に答える 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をサポートしているかどうかを確認することです。これは、デバイスがiBeaconを見つけるためにBluetooth LE(つまり、Bluetooth 4)をサポートしている必要があるためです。CoreLocationをインポートして、以下を使用するだけです。

迅速:

if (CLLocationManager.isMonitoringAvailable(for: CLBeaconRegion.self)){
    print("Bluetooth LE is supported")
}

Objective 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 に答える