0

I'm developping an app, that one one his tasks, is to send messages in tcp to a server. I want that the app continuos sending that tcp messages, even if the user quits the app.

I've that I could do that with:

"In your Info.plist set LSBackgroundOnly to 1."

But it don't work (I just tested on the simulator).

Thanks a lot for the help!

88fsantos
  • 393
  • 1
  • 7
  • 22
  • 1
    you are unlucky, because there are only three services allowed to run in the background: `location services`, `audio` and `VoIP`, any other thread will be suspended when the application goes to the background or the device goes to sleep mode, and when the user quits the application, the application will be terminated permanently. – holex Jul 24 '12 at 16:24
  • `LSBackgroundOnly` literally means your app can *only* run in the background—it could never be in the foreground. Obviously, that isn't available on iOS. – Peter Hosey Jul 24 '12 at 22:47

1 Answers1

3

I'll just put Holex's comment into answer form to take care of this question. As he states, there are only 3 types of services allowed to run in the background of an application, location services, audio, and VoIP. A great read on what you can and cant do is the following http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html from Apple. Fairly detailed article of the structure of what happens when an application loses focus.

Alternatively however, if you don't plan on releasing through the app store, it is possible to fake a VoIP application and send/receive messages in the background. This is not a legitimate solution however, and really should be used for nothing other than if you need something quick, and extremely dirty.

iOS Voip Socket will not run in background That question, and any related ones are good places to start.

Community
  • 1
  • 1
Karoly S
  • 3,180
  • 4
  • 35
  • 55