Reputation: 31
We have implemented HTML5 Web socket in my iPhone and iPad app. Web Socket works fine when app goes background (iPad/iPhone is not in lock state). But it gets disconnect when iPhone or iPad gets lock.
Is there any way to keep web socket running even when iPhone/iPad is lock?
Thanks.
Upvotes: 3
Views: 1802
Reputation: 1345
According to my own experiments. When you lock the device, the device seems to shut down WiFi and close network sockets, most likely in order to save power. The mobile broadband connections remains active though, and sockets seem to survive. At least for some time.
Have you tried to wrap the some parts of the socket code inside a beginBackgroundTaskWithExpirationHandler()? This should at least allow you to gracefully close the socket, or keep the socket alive for some time. The OS will, however, kill your task it after a global timer expires.
Upvotes: 1