WatchOS 4应用程序:CBCentralManager状态始终位于CBManagerStateUnsupported中

时间:2017-10-26 13:52:06

标签: ios objective-c core-bluetooth watch-os-4

我正在开发Apple Watch Series 3的应用程序,似乎CBCentralManager的状态始终为CBManagerStateUnsupported

我使用以下代码:

#import <CoreBluetooth/CoreBluetooth.h>

- (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
    NSString *stateString = nil;
    switch(central.state)
    {
        case CBManagerStateResetting:
            stateString = @"The connection with the system service was momentarily lost, update imminent.";
            break;
        case CBManagerStateUnsupported:
            stateString = @"The platform doesn't support Bluetooth Low Energy.";
            break;
        case CBManagerStateUnauthorized:
            stateString = @"The app is not authorized to use Bluetooth Low Energy.";
            break;
        case CBManagerStatePoweredOff:
            stateString = @"Bluetooth is currently powered off.";
            break;
        case CBManagerStatePoweredOn:
            stateString = @"Bluetooth is currently powered on and available to use.";
            [central scanForPeripheralsWithServices:nil options:
             [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:0]
                                         forKey:CBCentralManagerOptionShowPowerAlertKey]];
            break;
        default:
            stateString = @"State unknown, update imminent.";
            break;
    }
}

我做错了什么?

0 个答案:

没有答案