In VoIP apps using Apple CallKit (like yours), you can enable and disable proximity monitoring during the call using AVAudioSession()
class. It's a known feature when a proximity sensor is triggered and a screen is dimmed while approaching user's face.
By default (if you're not using CallKit) proximityMonitoringEnabled
instance property is OFF
.
@property(nonatomic, getter=isProximityMonitoringEnabled) BOOL proximityMonitoringEnabled;
// or
UIDevice.currentDevice.proximityMonitoringEnabled = NO; // DEFAULT VALUE
Apple's developer documentation says:
Enable proximity monitoring only when your application needs to be notified of changes to the proximity state. Otherwise, disable proximity monitoring. The default value is NO.
However, if you use CallKit module, proximityMonitoringEnabled
is not behaving as expected. By default a proximity monitoring is enabled – your app use for that a AVAudioSessionModeVoiceChat global variable:
const AVAudioSessionMode AVAudioSessionModeVoiceChat; // DEFAULT VALUE
Here's what developer documentation says here:
If an app uses the Voice-Processing I/O audio unit and has not set its mode to one of the chat modes (voice, video, or game), AVAudioSessionModeVoiceChat
mode will be set implicitly.
Disabling proximity monitoring in CallKit :
Hence, if you want to disable a proximity monitoring just use a AVAudioSessionModeVideoChat global variable:
const AVAudioSessionMode AVAudioSessionModeVideoChat;
Both variables work along with AVAudioSessionCategoryPlayAndRecord global variable:
const AVAudioSessionCategory AVAudioSessionCategoryPlayAndRecord;