title: CallKit issue with Speaker, Automatically turned On after receiving the call
body: <p>I'm using <code>CallKit</code> with <code>TokBox</code> and some how it is working with one bug, i.e after receiving the call, the speaker becomes active and can not be disabled by tapping on it. Call is starting with active speaker which I think is a bug, but WhatsApp and FBMassenger have used the same with their custom calling screen View, but their speaker become inactive after receiving the call, which I searched and no relevant answer I have been found so far.</p>
  
  <p>In <code>TokBox</code> they provided <code>OTDefaultAudioDevice.h</code> and <code>OTDefaultAudioDevice.m</code> file from where they configured all about audio with <code>CallKitSpeakerBox</code>. Where I found following configuration:</p>
  
  <pre><code>#define AUDIO_DEVICE_HEADSET     @"AudioSessionManagerDevice_Headset"
  #define AUDIO_DEVICE_BLUETOOTH   @"AudioSessionManagerDevice_Bluetooth"
  #define AUDIO_DEVICE_SPEAKER     @"AudioSessionManagerDevice_Speaker"
  </code></pre>
  
  <p>Which has been used as following way:</p>
  
  <pre><code>- (BOOL)configureAudioSessionWithDesiredAudioRoute:(NSString*)desiredAudioRoute
  {
      OT_AUDIO_DEBUG(@"configureAudioSessionWithDesiredAudioRoute %@",desiredAudioRoute);
  
      AVAudioSession *audioSession = [AVAudioSession sharedInstance];
      NSError *err;
  
      //ios 8.0 complains about Deactivating an audio session that has running
      // I/O. All I/O should be stopped or paused prior to deactivating the audio
      // session. Looks like we can get away by not using the setActive call
      if (SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(@"7.0")) {
          // close down our current session...
          [audioSession setActive:NO error:nil];
      }
  
      if ([AUDIO_DEVICE_BLUETOOTH isEqualToString:desiredAudioRoute]) {
          [self setBluetoothAsPrefferedInputDevice];
      }
  
      if (SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(@"7.0")) {
          // Set our session to active...
          if (![audioSession setActive:YES error:&amp;err]) {
              NSLog(@"unable to set audio session active: %@", err);
              return NO;
          }
      }
  
      if ([AUDIO_DEVICE_SPEAKER isEqualToString:desiredAudioRoute]) {
          // replace AudiosessionSetProperty (deprecated from iOS7) with
          // AVAudioSession overrideOutputAudioPort
  #if !(TARGET_OS_TV)
          [audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker
                                          error:&amp;err];
  #endif
      } else
      {
          [audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideNone
                                          error:&amp;err];
      }
  
      return YES;
  }
  </code></pre>
  
  <p>Where <code>AVAudioSessionPortOverrideSpeaker</code> used for all devices, which I believe is the main reason for becoming enabled speaker, though I don't know exactly. i.e</p>
  
  <pre><code>if ([AUDIO_DEVICE_SPEAKER isEqualToString:desiredAudioRoute]) {
              // replace AudiosessionSetProperty (deprecated from iOS7) with
              // AVAudioSession overrideOutputAudioPort
      #if !(TARGET_OS_TV)
              [audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker
                                              error:&amp;err];
      #endif
          } else
          {
              [audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideNone
                                              error:&amp;err];
          }
  }
  </code></pre>
  
  <p>Does any one have any suggestion or does any one here who have corrected that state so far?</p>
  
  <p>I also believe that many like me is going through this issue.</p>
  
  <p>Any help will be appreciable.</p>
  
  <p>Thanks</p>