iOS 17 AVAudioSession .allowBluetooth issue

in iOS 17 (21A5326A) audioSession.setCategory(.playAndRecord, mode: .default,options: .allowBluetooth) does not set input to bluetooth. In iOS 16 it does.

Here the steps to reproduce: Create project with storyboard. in info.plist add <key>NSMicrophoneUsageDescription</key> <string>Your microphone will be used to record your speech when you press the "Start Recording" button.</string>

put in ViewController:

import UIKit import Speech

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
}

override public func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
        
    AVAudioSession.sharedInstance().requestRecordPermission { granted in
     
    }
        
}


func startAudioSession(){
        let audioSession = AVAudioSession.sharedInstance()
            
        do {
          try audioSession.setCategory(.playAndRecord, mode: .default,options: .allowBluetooth)
                              
            try audioSession.setActive(true,options: .notifyOthersOnDeactivation)
            print(audioSession.currentRoute.description)
        } catch {
          
        }
    
}


@IBAction func btnTap(_ sender: UIButton) {
    startAudioSession()
}

}

put button on the Main.storyboard and link it to btnTap

Connect bluetooth headset to iphone, start the App and tap button. in iOS 16 see the current route - bluetooth. in iOS 17 see the current route - speaker

Accepted Reply

Wondering if you found any temporary workaround for this?

  • No

  • Seems to be resolved in the latest public beta

  • I'm reproducing the same issue on iSO 17.0.x and 17.1 beta. Did anyone find a workaround for this, or an official reference explaining the root cause? Thanks!

Add a Comment

Replies

Wondering if you found any temporary workaround for this?

  • No

  • Seems to be resolved in the latest public beta

  • I'm reproducing the same issue on iSO 17.0.x and 17.1 beta. Did anyone find a workaround for this, or an official reference explaining the root cause? Thanks!

Add a Comment