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.
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.