I am loading a local html file with this inside <script>
window.webkit.messageHandlers.MyHandler.postMessage("hello");
What changes do i need on my swift file to handle setup this handler?
my current swift file :
struct WebView: UIViewRepresentable {
    var url: URL
    ...
    func makeUIView(context: Context) -> WKWebView {
        // do configuration here
        let view = WKWebView()
        view.navigationDelegate = context.coordinator
        view.load(URLRequest(url: url))
        return view
    }
    ...
Thanks.
Tried this:
    func makeUIView(context: Context) -> WKWebView {
        
        let userController = WKUserContentController()
        userController.add(self, name: "MyHandler")
        let configuration = WKWebViewConfiguration()
        configuration.userContentController = userController
        return WKWebView(frame: frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, idealHeight: 500, maxHeight: .infinity) as! CGRect, configuration: configuration)
but i'm getting error on self: Argument type 'WebView' does not conform to expected type 'WKScriptMessageHandler'