0

I am trying to turn on Bluetooth automatically using my app. The usual way would be for the user to go to settings and turn on. But I need to to be turned on from the app. I have gone through lots of documentation and they are referring to private APIs but all are very old. I do not mind that it's not going to be approved at App Store.

Is there any way to turning on Bluetooth programmatically?

Cœur
  • 37,241
  • 25
  • 195
  • 267
L.William
  • 382
  • 1
  • 4
  • 20

2 Answers2

5

Is there any way or hack to turning on Bluetooth programmatically?

There is no provision to turning on Bluetooth programmatically. We can only notify user If the user has turned off Bluetooth all you can do is display an alert or message asking them to turn it on.

Refer CBCentralManager for monitoring Bluetooth state.

Hitesh Surani
  • 12,733
  • 6
  • 54
  • 65
2

To the community, sorry for the frustration but I am posting the answer myself now for devs in the future in case anyone needs to know. Just felt the community can do alot better than this, Stacksoverflow was supposed to be a community where devs help each other. IT CAN be done, however it's by private framework which CAN BE FOUND. An example would be using BeeTee, https://github.com/michaeldorner/BeeTee . It enables bluetooth to be turned on and the usage is given there by

class Demo: BeeTeeDelegate {
let beeTee = BeeTee()

init() {
    beeTee.delegate = self
    beeTee.enableBluetooth()
  }
}
L.William
  • 382
  • 1
  • 4
  • 20
  • Yes, but it says that "Based on the AppStore guideline §2.5 on private (undocumented) functions it is not possible to publish apps with the BeeTee and BluetoothManager.framework in the AppStore.". It worths mentioning. – malvarez Aug 16 '19 at 16:05