gpt4 book ai didi

ios - 在 ios 后台持续显示 "Turn on Bluetooth to allow app to connect to accessories"警报消息

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:13:21 26 4
gpt4 key购买 nike

我在我的应用程序中使用了 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;
}
}

enter image description here

问题:上面的警告消息经常在后台或其他应用程序打开时提示,即使我已经终止了该应用程序。我想显示此默认警报消息,但仅当用户打开应用程序时才显示。

谁能给我一个解决方案?

最佳答案

self.bluetoothManager = [[CBCentralManager alloc] initWithDelegate:self
queue:nil
options:@{CBCentralManagerOptionShowPowerAlertKey: @NO}];

这可能会隐藏系统弹出窗口。

关于ios - 在 ios 后台持续显示 "Turn on Bluetooth to allow app to connect to accessories"警报消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34132088/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com