Kaushik
Kaushik

Reputation: 1

How to keep Alive PJSIP alive in background mode for iOS

Hi i have read almost all tutorials to keep awake ios app but no luck. i had set acc.cfg transport = tcp , and keepalivetimeout handler ,and background modes as voip. and i have checked in activesocket class of library function is getting called to pair CFstreampropertyforvoip.

if any one has successfully able to awake pjsip in background mode.please share some information or snippet.

Upvotes: 0

Views: 1679

Answers (2)

bishopthom
bishopthom

Reputation: 691

There is no way to keep your app awake when in the background unless you register for the 'Audio and Airplay' background mode and then play an audio file to keep iOS from preempting normal runtime processing. MMPDeepSleepPreventer is an excellent resource for accomplishing this is by periodically playing a silent WAV file.

It is possible to use the VoIP socket flag (kCFStreamNetworkServiceTypeVoIP) but the flag must be set on a an existing, connected TCP socket. When your app is backgrounded, it will suspend like any other however iOS will take over monitoring the connection for incoming data and wake your app to properly process incoming information. The caveat is that there are hard limits to how often iOS will wake your application in a given amount of time before terminating it for misbehavior.

In addition, there is a beginBackgroundTaskWithExpirationHandler call that can be used to register a background 'house keeping' method that will be called by the operating system, at a 10 minute minimum period, to give your app a chance to do any short-term communication, connection management, etc.

Upvotes: 0

manash
manash

Reputation: 7106

You can use TCP transport for that but you should consider battery and bandwidth usage since your clients will need to continuously register and keepalive.

Another solution is to use PUSH. The idea is simple. When your client goes to background, it must unregister so that no registration exists on the server. Then, if an incoming call arrives, the server will not find any registration for the callee and will send a PUSH notification. When the client gets the PUSH notification, the user can tap the notification and the client opens and registers. Finally, the server correlates the incoming call with the received registration request, and finally forwards the incoming call to the client.

The advantages of using PUSH are:

  • Less battery usage
  • Less bandwidth usage
  • Ability to use UDP as transport protocol

The main drawback is the added complexity of implementing the whole flow (PUSH, suspending transaction...).

Upvotes: 1

Related Questions