以编程方式打开蓝牙 Swift

Turning on Bluetooth programmatically Swift

我正在尝试使用我的应用程序自动打开蓝牙。通常的方法是让用户转到设置并打开。但我需要从应用程序中打开。我浏览了很多文档,它们指的是私有 API,但都非常陈旧。我不介意它不会在 App Store 上获得批准。

有没有办法以编程方式打开蓝牙?

是否有任何方法或黑客以编程方式打开蓝牙?

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.

参考CBCentralManager监控蓝牙状态。

致社区,对于让您失望的事情,我深表歉意,但我现在将自己发布答案供将来的开发人员使用,以防有人需要知道。只是觉得社区可以做得比这更好,Stacksoverflow 应该是一个开发人员互相帮助的社区。它可以完成,但是它是通过可以找到的私有框架完成的。一个例子是使用 BeeTee, https://github.com/michaeldorner/BeeTee 。它可以打开蓝牙,使用方法由

给出
class Demo: BeeTeeDelegate {
let beeTee = BeeTee()

init() {
    beeTee.delegate = self
    beeTee.enableBluetooth()
  }
}