0

我正在为 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;
    }
}

我究竟做错了什么?

4

0 回答 0