davidstump / SwiftPhoenixClient

Connect your Phoenix and iOS applications through WebSockets!
MIT License
507 stars 147 forks source link

How to handle socket in background state #192

Closed srikanth-chetu closed 3 years ago

srikanth-chetu commented 3 years ago

Hi Team,

When we are clicking on the home button on the device, automatically presence diff is calling and the user going offline. Please suggest, how to keep socket connection always. And how to integrate with CallKit .

dsrees commented 3 years ago

You can't guarantee the socket will remain open while the app is in the background. iOS can kill your process at any time and the reconnection logic inside the client does not handle app lifecycle.

I've added code to the ChatRoomViewController example on how to handle reconnecting the socket when the app enters/exits the foreground in #196.

As for CallKit, I'm not familiar with it so I cannot provide much insight on using that with SPC.