accessing network from headless WKWebView

I am trying to use an invisible WKWebView to run a (3rd party) javascript API that talks to a server over websockets. It works fine in the simulator, but will not establish a connection on iOS unless the WKWebView is in the view hierarchy. Possibly, I can live with that, but it makes me wonder whether this approach is too brittle. Is this behavior documented anywhere? What would be a better approach?

Replies

Simulator runs a stack for macOS. On iOS, without a parent view, you're foregoing the standard APIs that are otherwise needed and help complete the talk-thru necessary for your connection to complete.


And before you ask, I have no idea if those APIs could be sufficiently identified and added to a standalone iOS WKWebView implementation that would survive, etc. Even if they did, it would seem coals-to-newcastle, and much easier to just do it BTB in the first place.