I am trying to detect that the iPhone user's bluetooth is on or off. If it is turned off, I want to send a notification to the user to turn it on. So far I have done this:
import CoreBluetooth class ViewController: UIViewController, CLLocationManagerDelegate,AVCaptureMetadataOutputObjectsDelegate,CBManager { var myBTManager = CBPeripheralManager(delegate: self, queue: nil, options: nil) } func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager!) { print(#function) if peripheral.state == CBManagerState.poweredOn { print("Broadcasting...") // myBTManager!.startAdvertising(_broadcastBeaconDict) } else if peripheral.state == CBManagerState.poweredOff { print("Stopped") myBTManager!.stopAdvertising() } else if peripheral.state == CBManagerState.unsupported { print("Unsupported") } else if peripheral.state == CBManagerState.unauthorized { print("This option is not allowed by your application") } }
But as you see in the picture, something is wrong. 
Could you help me solve this problem, I am new to the fast CoreBluetooth technology. I also use Reachability to detect Wi-Fi connections, so if it also works for Bluetooth, I would rather use Reachability.
source share