abhimanyu jindal abhimanyu jindal -3 years ago 173
iOS Question

iOS Audio not working during call answered when phone is locked. WebRTC used for calling

I am facing a problem with Audio When using Callkit with WebRTC for VOIP call, While answering the call from Lock Screen.

General Functionality :

My app activates the audioSession when it's launched. For an incoming call, SDP Offer & Answer are generated and exchanged. Peer Connection is set up. Both audio and video streams are generated, whether it's audio call or video call. Then Call is reported to callkit by using the following code:

callProvider.reportNewIncomingCall(with: currentCallUUID!, update: update) { error in }

If app is in the foreground, it works fine.

But, when the phone is locked, and user answers the call from lock screen, the Streams are exchanged but no audio comes on either end until user enters into the app himself.

As the user enters into the App, audio becomes active on both the ends.

All the background settings and capabilities are set properly.

I have also referred to the following work around provided by Apple staff. But even it does not work.


As I mentioned, I am using WebRTC for calling. If I exchange the media streams after the user answers the call( still on Lock Screen) and peer connection is set at that time. It works fine (But it adds the delay in making the call connection).

But if Peer Connection is made before displaying call (say before reporting call to callkit), the audio stops working.

Answer Source

I am able to resolve this issue.

Steps that I followed -

  • I checked the code related to WebRTC here

  • I added RTCAudioSession header file which is actually a private class of Webrtc. So every time I receive a call event from signaling, I enable RTCAudiosession and on end of the call, I disable it.

  • I have to render the incoming streams to a dummy view (Although it is not displayed when the call is going and the app is not yet open, but it is required to make audio working).

I hope this will help if someone is facing the same issue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download