|  |  | @ -98,14 +98,15 @@ import AVFoundation | 
			
		
	
		
		
			
				
					
					|  |  |  |         if call.hasLocalVideo { |  |  |  |         if call.hasLocalVideo { | 
			
		
	
		
		
			
				
					
					|  |  |  |             setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, |  |  |  |             setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, | 
			
		
	
		
		
			
				
					
					|  |  |  |                             mode: AVAudioSessionModeVideoChat, |  |  |  |                             mode: AVAudioSessionModeVideoChat, | 
			
		
	
		
		
			
				
					
					|  |  |  |                             options: .defaultToSpeaker) |  |  |  |                             options: [.defaultToSpeaker]) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } else if call.isSpeakerphoneEnabled { |  |  |  |         } else if call.isSpeakerphoneEnabled { | 
			
		
	
		
		
			
				
					
					|  |  |  |             setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, |  |  |  |             setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, | 
			
		
	
		
		
			
				
					
					|  |  |  |                             mode: AVAudioSessionModeVoiceChat, |  |  |  |                             mode: AVAudioSessionModeVoiceChat, | 
			
		
	
		
		
			
				
					
					|  |  |  |                             options: .defaultToSpeaker) |  |  |  |                             options: [.defaultToSpeaker]) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } else { |  |  |  |         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |             setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, |  |  |  |             setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, | 
			
		
	
		
		
			
				
					
					|  |  |  |                             mode: AVAudioSessionModeVoiceChat) |  |  |  |                             mode: AVAudioSessionModeVoiceChat, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             options: [.allowBluetooth]) | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -150,7 +151,7 @@ import AVFoundation | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else { |  |  |  |         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |             setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, |  |  |  |             setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, | 
			
		
	
		
		
			
				
					
					|  |  |  |                             mode: AVAudioSessionModeVoiceChat, |  |  |  |                             mode: AVAudioSessionModeVoiceChat, | 
			
		
	
		
		
			
				
					
					|  |  |  |                             options: .mixWithOthers) |  |  |  |                             options: [.mixWithOthers, .allowBluetooth]) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         // HACK: Without this async, dialing sound only plays once. I don't really understand why. Does the audioSession |  |  |  |         // HACK: Without this async, dialing sound only plays once. I don't really understand why. Does the audioSession | 
			
		
	
	
		
		
			
				
					|  |  | @ -299,6 +300,8 @@ import AVFoundation | 
			
		
	
		
		
			
				
					
					|  |  |  |     private func setAudioSession(category: String, |  |  |  |     private func setAudioSession(category: String, | 
			
		
	
		
		
			
				
					
					|  |  |  |                                  mode: String? = nil, |  |  |  |                                  mode: String? = nil, | 
			
		
	
		
		
			
				
					
					|  |  |  |                                  options: AVAudioSessionCategoryOptions = AVAudioSessionCategoryOptions(rawValue: 0)) { |  |  |  |                                  options: AVAudioSessionCategoryOptions = AVAudioSessionCategoryOptions(rawValue: 0)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         assert(Thread.isMainThread) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         do { |  |  |  |         do { | 
			
		
	
		
		
			
				
					
					|  |  |  |             if #available(iOS 10.0, *), let mode = mode { |  |  |  |             if #available(iOS 10.0, *), let mode = mode { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 try AVAudioSession.sharedInstance().setCategory(category, mode: mode, options: options) |  |  |  |                 try AVAudioSession.sharedInstance().setCategory(category, mode: mode, options: options) | 
			
		
	
	
		
		
			
				
					|  |  | 
 |