centrifugal / centrifuge-swift

Swift client SDK for bidirectional real-time communication with Centrifugo and Centrifuge-based server over WebSocket
MIT License
49 stars 44 forks source link

Inquiry about connection closure when app goes to background #88

Closed HudaElhady closed 1 year ago

HudaElhady commented 1 year ago

Description:

I would like to inquire about the behavior of the connection in the centrifuge package when the iOS app goes into the background. The package documentation mentions that the connection may be closed shortly after the app enters the background due to OS-specific limitations. However, during my testing, I observed that the connection seemed to be closed immediately, regardless of the available OS resources.

Additional Information:

To ensure a thorough understanding of the package's behavior and any potential workarounds, I would greatly appreciate clarification on the following points:

Does the centrifuge package indeed close the connection immediately when the app goes into the background? If the closure is immediate, is there any recommended approach or workaround to maintain the connection or receive socket messages while the app is in the background even if it will be for a short/limited time?

Thank you for your assistance in clarifying these questions. I appreciate your time and support.

FZambia commented 1 year ago

Hello, it's recommended to close real-time connection upon going to background. If you really want to keep the connection check out this SO post - it may give some insights how to achieve it on iOS.

Centrifuge-Swift package itself does not close connection upon going to background - but the example we have in the repo does.