Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
how to communicate between WKWebView in swiftUI with javascript in HTML5

I use WKWebView within swiftUI,may I please ask how can I communicate between Javascript in Html5 and webkit? I use userContentController, and also called userContentController.add(messageHandler, name: "messageHandler"), but I couldn't find the webkit property in window property in the Html5,it is undefined. I don't know how to adjust my code, and how to call the webkit to communicate with the webkit to WKWebkit in Javascript, below is my code

 func updateUIView(_ uiView:WKWebView,context:Context) {
        if let url = url, let requestURL=URL(string:url){
            let webConfiguration=WKWebViewConfiguration()
            let userContentController=WKUserContentController()
            webConfiguration.userContentController=userContentController
            
            uiView.load(URLRequest(url:requestURL))
            var cache=URLCache.init()
            URLCache.shared.removeAllCachedResponses()
            URLCache.shared.diskCapacity=0
            URLCache.shared.memoryCapacity=0;            
            userContentController.add(messageHandler, name: "messageHandler")

        }
        
    }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda