开发者

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 B开发者_JAVA百科luetooth 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.


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.


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜