I am using the following code to detect available outputs and it isn't picking up my connected bluetooth device. I know that my bluetooth device is properly connected because I am playing music from it.
let session = AVAudioSession.sharedInstance()
for description in session.currentRoute.outputs {
if description.portType == AVAudioSessionPortHeadphones {
NSLog("headphone plugged in")
let alertActin = UIAlertAction(title: "Headphones", style: UIAlertActionStyle.default, handler:nil)
alertActin.setValue(UIColor.blue, forKey: "titleTextColor")
alert.addAction(alertActin)
} else if description.portType == AVAudioSessionPortBluetoothA2DP {
NSLog("Bluetooth plugged in")
let alertActin = UIAlertAction(title: description.portName, style: UIAlertActionStyle.default, handler:nil)
alertActin.setValue(UIColor.blue, forKey: "titleTextColor")
alert.addAction(alertActin)
} else if description.portType == AVAudioSessionPortBluetoothLE {
NSLog("Bluetooth plugged in")
let alertActin = UIAlertAction(title: description.portName, style: UIAlertActionStyle.default, handler:nil)
alertActin.setValue(UIColor.blue, forKey: "titleTextColor")
alert.addAction(alertActin)
}
else {
NSLog("")
}
}