web_socket icon indicating copy to clipboard operation
web_socket copied to clipboard

Add an example for foreground service

Open sagar1garg opened this issue 1 year ago • 1 comments

Hi @dvmatyun ,

Could you add an example showing how to make the socket a foreground service and switch between service and normal implementation when app is in background/closed and when it is active?

sagar1garg avatar May 05 '24 06:05 sagar1garg

hi @sagar1garg , as far as I know mobile OS (android & iOS) closes the socket connection itself when app is in the background, so you can not rely on stable connection when app is not active. For that purpose, I suggest you to use some scheduling triggers like local push notifications. If you have other information regarding background connection let me know. Later maybe I will add some functionality for "background synchronization" with server, but I doubt that it will be using webSocket connection (because Operating system just does not allow that). Let me know if you have any questions or maybe I got your idea wrong.

dvmatyun avatar May 16 '24 12:05 dvmatyun