3

Is there any way to programmatically check if Bluetooth is enabled on an iOS device?

I'm currently developing a native app in Objective-C and making use of GKSession and a custom peer picker rather than the GK Peer Picker.

Is it possible to grab values from the Settings application on load or attempt to send out a packet with Bluetooth to see if it failed? It seems as though GKSession doesn't even allow the developer to distinguish whether or not data is sent over Wifi or Bluetooth. I'm not looking to enable or disable Bluetooth in the app; I just want to check its status.

jonsca
  • 10,218
  • 26
  • 54
  • 62
Matt
  • 33
  • 1
  • 3
  • 1
    Check http://stackoverflow.com/questions/4955007/how-to-get-the-status-of-bluetooth-on-off-in-iphone-programatically – Jhaliya - Praveen Sharma Jun 27 '11 at 14:50
  • 2
    I'm not sure recommending private frameworks to the OP is a good idea. He may want to submit his application at a future date and that will get him rejected. – Perception Jun 27 '11 at 15:26
  • @Jhaliya, unfortunately I can't use any private APIs because the app will be pushed to the store. I should have noted that in my OP. – Matt Jun 27 '11 at 15:46

2 Answers2

3

Unfortunately (stupidly?) there is no way to do it. Sorry. If you want to use the private SDK methods linked to in one of the comments to your question you certainly can, but Apple statically analyze code at the point of submission, so it's unlikely you'd be able to get it through the approval process.

I would strongly recommend you file a feature request to Apple asking for that ability in a future update. You used to be able to check for Bluetooth using GameKit, but that ability was removed when GameKit started supporting WiFi connections as well as Bluetooth.

lxt
  • 31,146
  • 5
  • 78
  • 83
  • That's not what I wanted to hear but you seem to be right. I'll put in a feature request but I don't expect much to come off it. Thanks. – Matt Jun 27 '11 at 17:46
0

You can now check this using the CBCentralManager in iOS 7 and initialize it with the CBCentralManagerOptionShowPowerAlertKey option set.

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

Chris Maddern
  • 737
  • 5
  • 12