Question

My online app runs on iPhone-3GS iOS 4.3, use NSStream to communicate with server.

When I minimize the app, lock phone, and relaunch my app the streams will end.

So my app loses connection to server.

Anyone knows how to keep the connection after locking phone? Is it a feature of iOS multitask?

Was it helpful?

Solution

This is a feature of iOS. Networking connections of backgrounded apps are cut off. You need to request "VoIP" treatment: for this, you need to set the "voip" value for the Info.plist key UIBackgroundModes and then mark your socket as being a VoIP socket setting the kCFStreamNetworkServiceType of your socket to kCFStreamNetworkServiceTypeVoIP using CFReadStreamSetProperty.

See also the Apple iOS App Programming Guide, section Tips for Developing a VoIP App.

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