I am using websocket with Swift 2 to maintain some data between app and server. This websocket works fine in foreground and background state, but when I terminate ( kill ) app then websocket connection breaks. When coming again to the app it will start working again.
Notes:
So, any idea and suggestion appreciated about how to keep a live websocket when an app is in terminated ( kill ) state?
Thanks in advance!
A WebSocket connection can in theory last forever. Assuming the endpoints remain up, one common reason why long-lived TCP connections eventually terminate is inactivity.
WebSocket uses HTTP as the initial transport mechanism, but keeps the TCP connection alive after the HTTP response is received so that it can be used for sending messages between client and server.
You can decide to use any WebSocket-based protocol that supports Android. Regardless of your choice, though, you need to consider the entire spectrum of challenges you'll face when it comes to WebSockets.
It is not possible. When the user terminates the app everything goes with it, if that wasn't the case then users would have no way to stop apps doing strange things (other than to restart the whole device).
Additionally you should not try exotic things to get around system restrictions as this will (eventually) lead to app rejection of you release to the store and / or users who are unhappy with battery life when your app is running.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With