URLSessionWebSocketTask + WatchConnectivity on Background task

Hello, I am facing a technical issue which is not cover by iOS Background Execution exemples, and I am looking for some help.

Context

I am doing a WatchOS App which allow to display websocket text messages for entertainment purpose. An average of 3000 can be connected to the same channel, the message rate may be high.

Process

The IOS (Iphone) app create a websocket connection with wss://irc-ws.chat.twitch.tv:443and transfer all those message to the WatchOS (Apple Watch) app.

Issues

When the IOS app is put in background, everything stops. This is logical because the application works as a proxy. The IOS app only allows searching and connect to channels, and it seems normal to put it in background.

Knowledges

I already did some researches about background task. I already understand many concepts like : stop the process as soon as possible, save battery life, optimization ect ... But I can't see my situation in any of the examples cover by documentations.

Background tasks (Question)

Is it possible to continue my websocket connection and the watch connectivity in background ?

This question leads to others :

  • Is the websocket (for text messages) can be considered as an URLSession background transfer ? Describe here
  • Is Watch Connectivity can be consider as a Background Processing Task or another task ? And which API to use ?
  • How long can the proxy process continue in background?

What I expect for my user

The perfect userflow which merge Apple Background restriction and user expectation could be :

  • 1- the user opens the app on the watch and the phone.
  • 2- the user does some stuff like search and connect to a channel.
  • 3- he put the IOS app in background to do other stuff on his phone
  • 4- the watchOS continue to receive and display messages (for maybe 1–2 hours)
  • 5- If the user close or leave the Watch app for more than (approximately) 2 min, the background process stops itself by a success.
  • 6- the user needs to reopen the Phone app to restart the process.
URLSessionWebSocketTask + WatchConnectivity on Background task
 
 
Q