The app needs to record sound through HFP, but play sound through A2DP.
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with:[AVAudioSessionCategoryOptions.allowBluetooth, AVAudioSessionCategoryOptions.allowBluetoothA2DP, AVAudioSessionCategoryOptions.mixWithOthers])
From what I understand, this will allow me to record and play sound with a bluetooth device that supports both HFP and A2DP. However, when I check the documentation, it says that
when a single device supports both the Hands-Free Profile (HFP) and the Advanced Audio Distribution Profile (A2DP), the Hands-Free ports will be given a higher priority for routing
So, the recording and playing both routes to HFP, and I can't find a way to force the playing through A2DP.
OK, there is no way to do this currently. I have verified this with Apple.