Telegraph
Telegraph copied to clipboard
Background
When the app goes it background I understand the server will shutdown, that is fine. But when the app is brought back to foreground it's not restarting. I have tried webserver start but that does not restart it. Can you tell me how to restart?
Hi! I recommend to stop the server when it goes to the background and then to (re)start the server when it comes out of the background. You can use the delegate methods of the AppDelegate for this.
Hi,
How do I stop the server?
Thanks
John
Sent from my iPhone
On 28 Aug 2021, at 22:50, Yvo van Beek @.***> wrote:
Hi! I recommend to stop the server when it goes to the background and then to (re)start the server when it comes out of the background. You can use the delegate methods of the AppDelegate for this.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
The Server object has both a start and a stop function:
https://github.com/Building42/Telegraph/blob/main/Sources/Server/Server.swift#L45
You could then for example stop the server in applicationWillResignActive and start it again in applicationWillEnterForeground. You might have to experiment a bit to find out which of the delegate calls works best.
Hey, is there a way to keep the connection open? Need this for authentication with another service... Thanks
Unfortunately on iOS devices, when the app is in the background the operating system will start closing connections for the app to save resources. For more info see https://github.com/Building42/Telegraph#what-if-the-device-goes-on-standby