title: How to detect other VOIP call (iOS)?
body: <p>I am working on an app that allows video calls using an SDK that utilises webRTC on iOS. </p>
  
  <p>Intended functionality is that if another call is instantiated after my app has instantiated a call, I want my app to mute audio in both directions in my call until that call has ended, in which case audio is restored. </p>
  
  <p>I have encountered a problem where I want to detect other calls that make VOIP calls (for example WeChat and Facebook Messenger).</p>
  
  <p>In the case of WeChat I have solved this exploiting that it interrupts the shared audio session (of AVAudioSession). The code that handles this is as follows: </p>
  
  <pre><code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector
       (audioSessionInterrupted:)
  ... 
  
  name:AVAudioSessionInterruptionNotification object:nil];
  - (void) audioSessionInterrupted:(NSNotification*)notification
  {
      if(notification.name == AVAudioSessionInterruptionNotification)
      {
          NSDictionary* userInfo = notification.userInfo;
          int result = userInfo[AVAudioSessionInterruptionTypeKey];
          if(result == AVAudioSessionInterruptionTypeBegan)
          {
              [[AVAudioSession sharedInstance] setActive:NO error:nil];
              [self setAudioEnabled:NO];
          }
          else if (result == AVAudioSessionInterruptionTypeEnded)
          {
              [[AVAudioSession sharedInstance] setActive:YES error:nil];
              [self setAudioEnabled:YES];
  
          }
      }
  }
  </code></pre>
  
  <p>However, for Facebook Messenger, this method is never called. I speculate from this that WeChat may be demanding exclusive access to the shared audio session (and thus causing an interruption of the audio session with my app) whereas Facebook Messenger chooses to mix its audio, or uses a separate audio session when a call is instantiated.</p>
  
  <p>My question is does there exist another way of detecting other VOIP calls, possibly using the CallKit framework? My app uses CallKit to prompt user for incoming calls, and records ingoing/outgoing calls in the iOS phone log. </p>