Question

I am working on an voip application, I need to maintain connection with the server always even when application goes background, apple is provding support to use communication socket, my problem is I have a separate server (i.e consider login server) I want to send ack to that sever in every 1 minute, I guess I can't have a two communication socket running for an application in background. In that case how do I send ack?

I have detached a thread from applicationDidEnterBackground it is also going suspend, What is the solution for my problem? Any idea?

Was it helpful?

Solution

Your application will never be always running in ios. U need to take help from push notification. Even if you use one socket, I dont think you it will run for more than predefined time. All voip app follows push notification in them.

Refer this link

    Declaring Your App’s Supported Background Tasks

    Support for some types of background execution must be declared in advance by the app that uses them. An app declares support for a service using its Info.plist file. Add the UIBackgroundModes key to your Info.plist file and set its value to an array containing one or more of the following strings:
 - audio—The app plays audible content to the user while in the
   background. (This content includes streaming audio or video content
   using AirPlay.)
 - location—The app keeps users informed of their location, even while
   it is running in the background.
 - voip—The app provides the ability for the user to make phone calls
   using an Internet connection.
 - newsstand-content—The app is a Newsstand app that downloads and
   processes magazine or newspaper content in the background.
 - external-accessory—The app works with a hardware accessory that needs
   to deliver updates on a regular schedule through the External
   Accessory framework.
 - bluetooth-central—The app works with a Bluetooth accessory that needs
   to deliver updates on a regular schedule through the Core Bluetooth
   framework.
 - bluetooth-peripheral—The app supports Bluetooth communication in
   peripheral mode through the Core Bluetooth framework.

    Each of the preceding values lets the system know that your app should be woken up at appropriate times to respond to relevant events. For example, an app that begins playing music and then moves to the background still needs execution time to fill the audio output buffers. Including the audio key tells the system frameworks that they should continue playing and make the necessary callbacks to the app at appropriate intervals. If the app does not include this key, any audio being played by the app stops when the app moves to the background. 

NOTE: Majority of void app works like user send one msg, server sends push notification to receiver, If receiver responds to push notification, msg is handled. Twist comes when user dont respond to push notification. This is handled when app is launched, user app Queries its server for any msg and that msg is then show in app interface. Hope this logic helps you.

OTHER TIPS

What you are proposing would be extremely battery intensive (the radio would never get a chance to idle). This would not be allowed in an App Store app.

You need to get info from the server via push notifications.

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