I am trying to list all the bluetooth connected audio devices. But there is no log in delegate functions. Also tried the solution from Switching audio output between Receiver and Speaker in iOS7 and above?
Following is my code...
import UIKit
import CoreBluetooth
import AVFoundation
class ViewController: UIViewController, CBCentralManagerDelegate, CBPeripheralManagerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
do{
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: AVAudioSessionCategoryOptions.AllowBluetooth)
} catch{
print(error)
}
let manager = CBCentralManager.init(delegate: self, queue: nil)
manager.scanForPeripheralsWithServices(nil, options: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func centralManagerDidUpdateState(central: CBCentralManager) {
print(central.state)
}
func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber) {
print(peripheral)
}
func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager) {
print(peripheral)
}
}
In my case, there is an audio player and a button(like the default airplay button in music). On clicking the button, it should display all the connected bluetooth devices. Is it possible to list all the devices? Also I cannot use Apple's MKVolumeView because I have to further create a cordova plugin.