Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone app network connection disconnect after screen locking with new ios sdk 5.0

Tags:

iphone

ios5

My app working with sdk 4.3 just fine, but when i change to sdk 5.0, every time the screen is locking, after just a few seconds, the tcp connection will disconnect.

I use xmppframework, and it gives me an error like

"Error Domain=NSPOSIXErrorDomain Code=57 The operation couldn’t be completed. Socket is not connected" 

It seems that the socket was been closed after screen locking.

Is there something changed in sdk 5.0 case this problem?

Regards.

like image 991
Rico Avatar asked Oct 23 '11 14:10

Rico


3 Answers

In iOS 4.x when the user initiated the lock screen the app continued to run in the background. Now in iOS 5.0 when the lock screen is initiated the app is sent to the background and you can only do what an app can do in the background. So if you have not made other arrangements than your app will loose network connections.

like image 111
Steve M Avatar answered Oct 20 '22 00:10

Steve M


Do you have UIRequiresPersistentWiFi specified in your info.plist file? The time it takes iOS to shut down WiFi without this setting may have changed between iOS 4.x and 5.0.

like image 22
Robin Summerhill Avatar answered Oct 19 '22 23:10

Robin Summerhill


When you lock your iphone or ipad, all the network activities are stopped. Wifi connections are dropped. With what Robin has stated, this would work if the ipad is in idle state and not locked. Since there would be no traffic incoming or outgoing, iPad might decide to drop connection to WiFi.

like image 35
VijayKumar Avatar answered Oct 20 '22 00:10

VijayKumar