5

iOS documentation says that CBCentralManagerOptionShowPowerAlertKey default value is NO.

I'm not specyfing ANY options while instantiating CBCentralManager

[[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue()];

but it still shows the "Turn On Bluetooth to Allow..." prompt.

Is it a bug in documentation, or am I doing something wrong ?

Edit:

I've found this:

http://chris.cm/determine-whether-bluetooth-is-enabled-on-ios-passively/

And this:

iOS CoreBluetooth passively check if Bluetooth is enabled without prompting user to turn Bluetooth on

which seem to suggest that you have to explicitly set the CBCentralManagerOptionShowPowerAlertKey to NO, which suggests that there is a bug in documentation ? I'm just looking for someone to confirm.

Edit 2:

after setting CBCentralManagerOptionShowPowerAlertKey to 0 the problem seems to be resolved. but I'm still looking for some explanation, because it seems highly illogical that the documentation says one thing and program another.

Community
  • 1
  • 1
michal.ciurus
  • 3,616
  • 17
  • 32

2 Answers2

1

Yes you are correct, I have this particular inconsistency in my code right now.

The docs says that NO it should be the default value but that isn't the case, you have to force it, the default behaviour is YES.

Mr.Me
  • 9,192
  • 5
  • 39
  • 51
0

Looking into the documentation as well, in the Programming Guide, creating a manager, there is this paragraph:

When you create a central manager, the central manager calls the centralManagerDidUpdateState: method of its delegate object. You must implement this delegate method to ensure that Bluetooth low energy is supported and available to use on the central device. For more information about how to implement this delegate method, see CBCentralManagerDelegate Protocol Reference.

I wonder if the prompt is part of that delegate call, if the state is "PoweredOff"

Logically it makes some sense, if you are launching and trying to communicate via bluetooth, this is something the user is expecting. They may not have bluetooth on, this covers that use case without forcing the user to go to the settings app, before they can use your app.

Naughty_Ottsel
  • 1,103
  • 10
  • 12