我在我的应用程序中使用iBeacon技术。我在应用程序中检查用户是否已启用或禁用蓝牙,并且我已在下面编写代码。
- (void)viewDidLoad
{
[super viewDidLoad];
_bluetoothManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:nil];
}
// bluetooth manager state change
- (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
NSString *stateString = nil;
switch(central.state)
{
case CBCentralManagerStateResetting: stateString = @"The connection with the system service was momentarily lost, update imminent."; break;
case CBCentralManagerStateUnsupported: stateString = @"The platform doesn't support Bluetooth Low Energy."; break;
case CBCentralManagerStateUnauthorized: stateString = @"The app is not authorized to use Bluetooth Low Energy."; break;
case CBCentralManagerStatePoweredOff: stateString = @"Bluetooth is currently powered off."; break;
case CBCentralManagerStatePoweredOn: stateString = @"Bluetooth is currently powered on and available to use."; break;
default: stateString = @"State unknown, update imminent."; break;
}
}
问题:以上警告消息经常在后台提示,或者当其他应用程序打开时,即使我已杀死该应用程序。我想显示此默认警报消息,但仅在用户打开应用程序时显示。
有人能为我提供解决方案吗?
答案 0 :(得分:6)
self.bluetoothManager = [[CBCentralManager alloc] initWithDelegate:self
queue:nil
options:@{CBCentralManagerOptionShowPowerAlertKey: @NO}];
这可能会隐藏系统弹出窗口。