2017-07-09 9 views
0

このセグメントがiPad Airで動作しているときにiOSデバイスでBluetoothがオンまたはオフになっているかどうかを確認しようとしています。Bluetooth Status: Turned OnまたはBluetooth Status: Turned Off私はBluetoothをオン/オフにします。しかし、これをiPad 2で実行すると、Bluetooth Status: Not Supportedが印刷されます。デバイスに関係なくBluetoothがオン/オフになっているかどうかを知る必要がある

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) 
    } 
} 

}

私の側から行方不明何かがあります! デバイスに関係なくBluetoothがオン/オフかどうかを知る必要があります。

答えて

0

iPad 2は、コアBluetoothによって公開されているBluetoothであるBLEをサポートしていません。これが、「サポートされていない」ステータスを取得する理由です。

レガシーBluetoothの電源ステータスを提供するAPIはありません。

+0

ありがとうございます。しかし、私は、BTのステータスを検出できるアプリ2のアプリを見ました。 Square Register Appのように! –

関連する問題