当前位置:  开发笔记 > 编程语言 > 正文

在ios的背景中连续显示"打开蓝牙以允许应用程序连接到附件"警报消息

如何解决《在ios的背景中连续显示"打开蓝牙以允许应用程序连接到附件"警报消息》经验,为你挑选了1个好方法。

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

在此输入图像描述

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

谁能为我提供解决方案?



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

这可能会隐藏系统弹出.

推荐阅读
jerry613
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有