title: AVAudioSession: Some Bluetooth devices are not working properly on my App
body: <p>I'm developing a swift audio/video and text chat iOS App using AVAudioSession.</p>
  
  <p>Whenever I select to use some Bluetooth devices the sound played on the device is not the App audio stream. They play only the system sound sent by text chat library whenever messages are sent/received instead. It doesn't happen on all Bluetooth devices, on some of them everything works fine. On Builtin Mic and Speaker the App works fine too.</p>
  
  <p>Here are the most important methods from my class to manage the device:</p>
  
  <pre><code>class MyAudioSession
  {
      private var mAudioSession: AVAudioSession;
  
      init!()
      {
          self.mAudioSession = AVAudioSession.sharedInstance();
  
          do {
              try self.mAudioSession.setActive(false);
  
              try self.mAudioSession.setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: .AllowBluetooth);
              try self.mAudioSession.setMode(AVAudioSessionModeVideoChat);
              try self.mAudioSession.setActive(true);
          }
          catch {
              return nil;
          }
      }
  
      func switchToDevice(device: AVAudioSessionPortDescription!) -&gt; Bool
      {
          var ret = false;
  
          if (device != nil) {
              do {
                  try self.mAudioSession.setPreferredInput(device);
  
                  ret = true;
              }
              catch {
                  self.logSwitch(device, error: error);
              }
          }
  
          return ret;
      }
  }
  </code></pre>
  
  <p>I'd like to understand why my App is not working fine on just SOME Bluetooth devices. These same devices work properly on the other Apps on my Cel.</p>
  
  <p>I did another test: I changed all of this for MPVolumeView, and exactly the same issue occurred, so the problem seems to be on audio player.</p>
  
  <p>Could anybody give me a suggestion to fix this ?</p>
  
  <p>Thx.</p>