iOS11蓝牙有些奇怪

时间:2017-09-26 12:09:50

标签: ios bluetooth ios11

当我在设置中关闭蓝牙时,我使用CBCentralManager来获取蓝牙的状态,如下所示:

self.bluetoothManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

系统会显示如下警告:system alert

蓝牙的当前状态为CBManagerStatePoweredOff。但是当我关闭控制中心的蓝牙时,即使蓝牙的当前状态仍为CBManagerStatePoweredOff,此警报也不再显示。

在这种情况下,如何提醒用户打开蓝牙?

2 个答案:

答案 0 :(得分:0)

您可以通过实施以下委托方法来提醒用户。

{{1}}

现在应该自动通知用户。

答案 1 :(得分:0)

您可以在选项dict中使用 CBCentralManagerOptionShowPowerAlertKey 来禁用系统蓝牙警报。

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

然后您可以使用删除方法 centralManagerDidUpdateState:来弹出自定义提醒。