Home > Blockchain >  Handle IOs app background process with Websocket and WatchOs Session
Handle IOs app background process with Websocket and WatchOs Session

Time:12-11

I have created an application that receives messages from a server connected via Websocket. All these messages are parsed and an action is sent to an Apple Watch with WCSession. All the logic is this 2 lines, 1 init the websocket - 2 link receive from websocket and send to watch protocol.

I need to allow the app to continue all this process in background (but not if the app is closed). The server is a chat (wss://irc-ws.chat.twitch.tv:443) so many messages must can received (30 to 100 per second). I don't need any UI change till the app is in background.

I am asking some help me to understand how to create a background processes :

I already saw this conf from WWC2019 https://developer.apple.com/videos/play/wwdc2019/707 so I understanded Apple good practices (end process as soon as possible, optimise process as possible...), but I don't know how to tell my app to continue specific processes when he is in background.

Thanks in advance to every advice or knowledge sharing.

CodePudding user response:

Handle websocket while background is not possible for a long time. A solution was to move the websocket logic in the watch.

  • Related