Matt
Matt

Reputation: 33

Checking Bluetooth Status

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.

Upvotes: 3

Views: 2656

Answers (2)

Chris Maddern
Chris Maddern

Reputation: 767

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/

Upvotes: 0

lxt
lxt

Reputation: 31294

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.

Upvotes: 3

Related Questions