Just out of curiosity so did a little search on this.
Here is the code example: https://gist.github.com/JSerZANP/ea30...
to summarize
1. userContentController for WKWebview to inject a bridge in webkit.messageHandlers
2. WKWebview.evaluateJavaScript to run piece of JavaScript code in webview runtime
Hi I'm a JavaScript engineer who is not good at algorithms,
and currently practicing leetCode & BFE.dev. If you are interested, maybe we can learn together.