我正在开发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;
}
}
我做错了什么?