gpt4 book ai didi

ios - 我需要知道蓝牙是否打开/关闭,无论设备如何

转载 作者:行者123 更新时间:2023-11-30 12:19:18 25 4
gpt4 key购买 nike

因此,当此段在我的 iPad Air 上运行时,我尝试检查 iOS 设备上的蓝牙是否打开或关闭,它打印 Bluetooth Status: Turned OnBluetooth Status:当我打开/关闭蓝牙时关闭。但是当我在 iPad 2 上运行它时,它会打印 Bluetooth Status: Not Supported

fileprivate var bluetoothPeripheralManager: CBPeripheralManager?

override init() {
super.init()
let options = [CBCentralManagerOptionShowPowerAlertKey:0]
bluetoothPeripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: options)
}

extension PrintersMonitor: CBPeripheralManagerDelegate{
func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager){
var statusMessage = ""

switch peripheral.state {
case .poweredOn:
statusMessage = "Bluetooth Status: Turned On"
case .poweredOff:
statusMessage = "Bluetooth Status: Turned Off"
case .resetting:
statusMessage = "Bluetooth Status: Resetting"
case .unauthorized:
statusMessage = "Bluetooth Status: Not Authorized"
case .unsupported:
statusMessage = "Bluetooth Status: Not Supported"
bluetoothPeripheralManager = nil
default:
statusMessage = "Bluetooth Status: Unknown"
}

log(statusMessage)

if peripheral.state == .poweredOn{
if state != .searching{
resume()
}
}else if peripheral.state == .poweredOff{
pause(isPrinting: false)
}
}

}

我这边是不是少了点什么!我需要知道蓝牙是否打开/关闭,无论设备如何!

最佳答案

iPad 2 不支持 BLE,这是 Core Bluetooth 公开的蓝牙。这就是为什么您的状态为“不支持”。

没有 API 可以提供传统蓝牙的电源状态。

关于ios - 我需要知道蓝牙是否打开/关闭,无论设备如何,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44993904/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com