Receive voice calls when app is in background in ios

I think that I have all the requirements to have a live socket when the application is in the background. I.e:

  • My app has voip and audio as background modes.
  • I use PJSIP as a SIP library, which should use CFReadStreams with the "Run in background" property enabled
  • The application uses TCP to establish a connection to the SIP server.

When an application is sent to the background, it adds a background handler that sends a “keepAlive” message every time period.

This keepAlive seems to work. If I check the logs on the server, I can see how the messages arrive, even if the application is not in the foreground.

The problem (and question) is that I do not receive calls when the application is in the background.

It seems that the socket is still alive, if I make a cell phone call, and the application is not in the foreground, nothing happens, but if I launch the application myself, the call will be automatically detected.

Thanks:)

+4
source share
2 answers

We found a problem.

Given the current configuration, the Server used a different connection to send an INVITE request from the original TCP socket used from the phone to send an internal REGISTER request.

Since both connectors were different, the operating system did not wake the application.

If you configured the server (in our case, Kamailio) to reuse the original socket that the phone used to send the first REGISTER, it works without problems.

By default, it seems that the SIP servers create new sockets for each INVITE request that they want to send to the phone. This situation is a problem for the iphone background model.

+4
source

To double check you read the following: http://trac.pjsip.org/repos/wiki/Getting-Started/iPhone#UnabletoacceptincomingcallinbackgroundmodeiOS4

Also, try with the latest branch 1.x from the Subversion repository, several fixes for iOS support have been fixed.

0
source

All Articles