Your client can't answer a call while the phone is locked. Or there's echo that annoys both speakers. Sometimes the call drops when an SMS arrives. These bugs are typical consequences of a poorly integrated VoIP. We solve them at the architecture level, leveraging experience in telemedicine, logistics, and corporate communications.
Implementing VoIP calls in a mobile app isn't a single task — it's several interconnected technical layers: signaling protocol, media transport, audio session management, and integration with system call APIs. Skipping or simplifying any of these layers means a call that works in a demo but breaks in production: echo, audio loss on incoming notification, inability to answer a call from the lock screen.
How CallKit works
On iOS, VoIP without CallKit is technically possible, but the app won't get an audio session for an incoming call when the screen is locked, the system won't show the system incoming call screen, and since iOS 13, apps without CallKit won't receive PushKit notifications for VoIP. CallKit is a system framework that displays the system incoming call screen, manages audio sessions, supports Bluetooth/AirPods, and displays calls in the call history.
import CallKit class CallManager: NSObject { let provider: CXProvider let callController = CXCallController() init() { let config = CXProviderConfiguration() config.supportsVideo = false config.maximumCallsPerCallGroup = 1 config.supportedHandleTypes = [.phoneNumber, .emailAddress] provider = CXProvider(configuration: config) super.init() provider.setDelegate(self, queue: nil) } func reportIncomingCall(uuid: UUID, callerName: String) { let update = CXCallUpdate() update.remoteHandle = CXHandle(type: .generic, value: callerName) update.hasVideo = false provider.reportNewIncomingCall(with: uuid, update: update) { error in // start answering call after system approval } } } PushKit for incoming calls in background. Unlike regular APNs push, PushKit wakes the app instantly with high priority. But since iOS 13, Apple requires immediately calling reportNewIncomingCall upon receiving a VoIP push — otherwise the app crashes. No network request before CallKit.
Android: ConnectionService and Telecom API
The Android counterpart to CallKit is ConnectionService from the android.telecom package. It allows the app to become a "phone account" in the system, show calls on the lock screen, and manage audio routing. For incoming calls in background — FCM push with priority: high. On Android 14+, background services are restricted, but ForegroundService of type phoneCall (added in Android 14) solves exactly this task — no startup restrictions for incoming calls.
Audio session management via AudioManager:
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager audioManager.mode = AudioManager.MODE_IN_COMMUNICATION audioManager.isSpeakerphoneOn = false // on call end: audioManager.mode = AudioManager.MODE_NORMAL Bluetooth headsets are a separate headache. BluetoothHeadset profile, SCO connection for voice (not A2DP!), BroadcastReceiver for ACTION_SCO_AUDIO_STATE_UPDATED. Without explicit SCO management, audio goes through the speaker even when a Bluetooth headset is connected.
Why a TURN server matters
If you use WebRTC on its own (rather than through Twilio/Vonage), you need a TURN server for NAT traversal. Without it, calls only work within one network — a classic demo bug that breaks when the client is behind a corporate NAT. A TURN server also helps with symmetric NATs where standard STUN doesn't work.
coturn is an open source TURN server, deployable on a VPS in a few hours. ICE configuration:
// Android WebRTC SDK val iceServers = listOf( PeerConnection.IceServer.builder("stun:stun.example.com:3478").createIceServer(), PeerConnection.IceServer.builder("turn:turn.example.com:3478") .setUsername("user") .setPassword("password") .createIceServer() ) Codecs: Opus for audio (adaptive bitrate 6–510 kbps, works well with up to 20% packet loss). WebRTC SDK includes it by default.
Audio codec selection details
Opus — an adaptive codec with bitrate from 6 to 510 kbps. Supports stereo and multi-channel audio. For compatibility with SIP phones, G.711 (PCMA/PCMU) or G.722 may be needed. When choosing a codec, consider client support, bandwidth, and quality requirements.Approach comparison: Managed SDK vs WebRTC
| Parameter | Managed SDK (Twilio, Agora) | WebRTC + TURN |
|---|---|---|
| Development complexity | Low | Medium |
| Cost per minute | ~$0.004–0.01 | ~$0.001 (own TURN) |
| Control | Limited | Full |
| Latency | Depends on SDK | Minimal (<100 ms) |
| Required resources | None | TURN server |
Managed SDKs are simpler, but WebRTC can save up to 80% on call costs with your own TURN infrastructure. At high volumes (over 10,000 minutes per month), the difference becomes significant.
Common mistakes and solutions
| Mistake | Solution |
|---|---|
| Echo | Set MODE_IN_COMMUNICATION on both platforms + AEC (acoustic echo cancellation) |
| Call doesn't arrive on lock screen | Integrate CallKit/ConnectionService |
| Latency >300 ms | Configure P2P ICE, TURN only as fallback |
| Interruption on SMS | Handle AVAudioSessionInterruptionNotification (iOS) and AudioManager (Android) |
| Bluetooth audio not switching | Explicit SCO management via BroadcastReceiver |
What's included in the work
- Requirements analysis and optimal stack selection (WebRTC, Twilio, Agora, or custom SIP).
- Signaling channel design (WebSocket, SIP, or custom protocol).
- TURN server deployment (coturn) and ICE candidate configuration.
- CallKit (iOS) and ConnectionService (Android) integration with PushKit/FCM.
- Testing on 20+ real devices with different OS versions and network conditions.
- Audio quality optimization: AEC, adaptive jitter buffer, packet loss concealment.
- Documentation and client team training.
- Post-launch support (monitoring, bug fixes, enhancements).
VoIP call development process
- Requirements analysis and stack selection (managed SDK vs WebRTC).
- Signaling and media channel design.
- TURN server deployment and ICE configuration.
- CallKit/ConnectionService and PushKit/FCM integration.
- Testing on real devices with various network conditions.
- Audio quality optimization and artifact elimination.
- Deployment and monitoring.
Contact us to discuss your VoIP solution architecture. Order development and we guarantee stable calls without echo or drops. Get a consultation from our engineer — we're ready to help.







