Question

I think i have all the requirements to have an "alive" socket while the app is in background. That is to say:

  • My application has voip and audio as its background modes.
  • I'm using PJSIP as the SIP library, which is supposed to use CFReadStreams with the "Run in Background" property enabled
  • The app is using TCP to establish the connection with the SIP server.

When the application is sent to background, it adds a background handler which sends a "keepAlive" message each period of time.

That keepAlive seems to be working. If I check the logs in the server I can see how messages arrive even when the application is not in foreground.

The problem ( and the question ) is, I'm not receiving calls while the application is in background.

It seems that the socket is still alive, if I make a call to the cell phone while the app is no in the foreground, nothing happens, but if I launch the app by myself, the call is automatically detected.

Thanks :)

Was it helpful?

Solution

We found the problem.

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

As the two sockets were different, the Operating System didn't wake the application.

If you configure the server (Kamailio in our case) to reuse the initial socket which the phone used to send the first REGISTER it works seamlessly.

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

OTHER TIPS

Just to double-check, you've read this: http://trac.pjsip.org/repos/wiki/Getting-Started/iPhone#UnabletoacceptincomingcallinbackgroundmodeiOS4

Also, try it with the latest 1.x branch from Subversion repository, there have been several fixes to iOS support.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top