Some general feedback:
WKWebView, as it's the latest web view for iOS/macOS.
Also with the question you asked you basically show they main flaw of this concept of an interface, where you depend on native elements to communicate from the window back to Sketch, which makes it difficult if not impossible to build a solid and even more functional GUI in the web view.
A better attempt in my opinion (which doesn't necessarily mean that it's the one true solution or even that if fits your use case better) is to provide the communication directly on the web view.
Send Data from Sketch to GUI via WKWebView:
That's pretty straight forward, as
WKWebView has a method
foo in your web view, you can call it via
Send Data from GUI to Sketch
This is a bit more challenging because the web view needs to define that bridge itself. You need to define additional configuration on the web view for that, e.g.:
const config = WKWebViewConfiguration.alloc().init();
const messageHandler = SPBWebViewMessageHandler.alloc().init();
const webView = WKWebView.alloc().initWithFrame_configuration(frame, config);
I define this
SPBWebViewMessageHandler in a separate framework written in obj c, but that's just because it seemed simpler to me, I guess you could also do it all in cocoascript. What it essentially does is handling the message you want to send, saving it to a local file somewhere and triggering a plugin entry point you can define where you can read out this file and handle the message in your js. Hope that makes a little bit of sense
In the end that will give you a method
window.webkit.messageHandlers.Sketch.postMessage you can call from within you web view.
You can have a look at the web view utils here and at the message handler in obj c here if you want to have a closer look at the code.
This second part is still quite obscure and I'm currently cleaning it up and writing a medium article about it in the hope to make it easier to grasp, but maybe you get an idea of what I was trying to say