Skip to content

Commit 57d83d7

Browse files
committed
respect silence switch for incoming ringing
// FREEBIE
1 parent 565db5a commit 57d83d7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Signal/src/view controllers/CallViewController.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,29 @@ import PromiseKit
5757

5858
private func handleLocalRinging() {
5959
Logger.debug("\(TAG) \(#function)")
60-
6160
audioManager.setAudioEnabled(true)
6261
audioManager.handleInboundRing()
62+
do {
63+
// Respect silent switch.
64+
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategorySoloAmbient)
65+
Logger.debug("\(TAG) set audio category to SoloAmbient")
66+
} catch {
67+
Logger.error("\(TAG) failed to change audio category to soloAmbient in \(#function)")
68+
}
69+
6370
vibrateTimer = Timer.scheduledTimer(timeInterval: vibrateRepeatDuration, target: self, selector: #selector(vibrate), userInfo: nil, repeats: true)
6471
}
6572

6673
private func handleConnected() {
6774
Logger.debug("\(TAG) \(#function)")
6875
stopRinging()
76+
do {
77+
// Start recording
78+
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)
79+
Logger.debug("\(TAG) set audio category to PlayAndRecord")
80+
} catch {
81+
Logger.error("\(TAG) failed to change audio category to soloAmbient in \(#function)")
82+
}
6983
}
7084

7185
private func handleLocalFailure() {

0 commit comments

Comments
 (0)