The idea of behind the way multitasking is handle in iOS, is to keep the battery life in a good shape and just keep the tcp sockets so far connected to wake the application, when something is happening on the connection.
The most VoIP application are using SIP, which is normally running on udp. And udp is not available for backgrounded application. So you might also get SIP via tcp, which has it‘s own merits and caveats.
SIP uses udp for the low latency and jitter purpose. It usually is okay for a listener, if some of the packets never made it to you and are dropped. We are all used to bad lines, we do not rely on perfect transmission. Means, it‘s fine to get crystal clear lines, but we also understand the opposite, if the drops are below a certain limit. udp is just build for that purpose.
Tcp on the other hand does retransmit packets until they reached the target, even if it has to stop the transmitting until this one piece of information has travelled. So with sip over tcp, the problem is not that we hear a bad line, but we could hear paused conversation, like stop and go on the highway.
If these stops getting above a level, our communication breaks down.
Technically there are some ways around this problem.
- Easiest way would be, not to stop the application. No background, no multicast, but working VoIP phone.
- Next idea: Use the tcp variant, which works perfect in public reachable networks. It will not work through nat or double nat setups and although not in vpn setups. But, we have multicast. And you should not leave the wifi you logged into the VoIP application, as the socket keeps that IP. So if you fallback to 3G or GSM, the connection is broke.
- Use of push notification. That could solve this disconnection bug of the previous idea. But you still need to have a public visible for VoIP server. No nat, double nat or vpn setups. And the biggest problem of all, you are going to give the push notification provider (aka your sip app programmer) your login in credentials to your sip account to be your proxy.
- So this is the setup I‘ll use to have a work around. My asterisk box notifies me via XMPP (jabber) of incoming phones calls. These jabber messages are using push notification to get to my jabber app (IM+). For privacy concerns, I have setup an extra account just for this. When I tap on the dialer number, I‘ll copy‘n‘paste them into the voip application, which uses my already discussed secure vpn sip connection. Not perfect, but working.
- One future way out of this would be IPV6, as there are no need for nat-ing and we could use IPSEC for encryption. iOS4.x supports IPV6 already….