5
votes

I am developing SIP and VoIP based iOS application and requirement is that the application should be continuously running even in background also.I am using pjsip lib.

I know that to run the iOS application in bacground,we need this

  • Set UIBackgroundModes key in Info.plist with voip value

  • Created a handler that I passed to setKeepAliveTimeout:handler: for keeping the connection alive

But I just want that if my application is running in background can I receive UDP packets over (RTP/RTCP),while I am keeping UDP port always open.

I have already gone through the posts:

But,I have not getting clear idea that can we get UDP packet continuously even the app is in background or foreground.

So that if there is any data is coming to iOS client app , the app should be able to notify the user.

Please give suggestions.

2
Hi lyon, Please go through stackoverflow.com/questions/6601536/… this post also, may be helpful for you.User97693321
You mean. You need a way to keep the app running in the background so that when there's a call it indicates you??Sharanya K M
btw... Which version of pjsip do you use? you use zrtp too?Sharanya K M

2 Answers

0
votes

In order to run VoIP app at the background and register on a server one should use TCP on iOS. When something happens you can fire local notification.

-1
votes

I think you can set local notifications when the app is running in background and indicate the user of an incoming call through the notification. When the user enters the application you can show the incoming call.

In the below link, check Background Execution and Multitasking and also Scheduling the Delivery of Local Notifications

IE since you have set the UIBackgroundModes key in Your Info.plist, your app will support long running tasks. So in the applicationDidEnterBackground method add a method which creates a UILocalNotification when there's a call. UILocalNotifications notifies the user with an alert message and a tone of your choice. So once the user is notified and user enters the app, the app will come to foreground where you can add the method for him to receive the call.

In the alert body of the LocalNotification you can send the caller's information to the user.

EDIT : Check out the answer of Paul Richter in this link, where he says

VOIP mode gives you the ability to have code running to notify you of a call coming in
 but you're not going to be able to record audio from the background. If you look at how
Voip apps work, when a call comes in a Local Notification is sent informing the user 
that a call is coming in. The User then must accept the call which will bring the 
application to the foreground at which point from the audio side of things you can 
activate your session and proceed with the phone call. 

Although not completely related to the library you are using, he has given a decent explaination of the process.

Hope this helps.