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

218
Visualizações
wkwebview not detecting phonenumbers when loading the html content using javascript

wkdatdetectortypes = .all is not detecting any of the data like phone numbers, address etc. in wkwebview. This is happening only when loading the html string using javascript. If it is done using loadHTMLString, the data is detected properly. can anyone help me in the regard. thank you.

here is my code for reference:

    let config = WKWebViewConfiguration()

    config.dataDetectorTypes = [WKDataDetectorTypes.all]



    webview = WKWebView(frame: .zero, configuration: config)

    webview.isUserInteractionEnabled = true

    webview.backgroundColor = .white

    webview.navigationDelegate = self

    webview.uiDelegate = self

    webview.allowsLinkPreview = true

    webview.translatesAutoresizingMaskIntoConstraints = false



    let bundleURL = Bundle.main.resourceURL!.absoluteURL

    let html = bundleURL.appendingPathComponent("index.html")           //index.html is in the same project file path.

    webview.loadFileURL(html, allowingReadAccessTo:bundleURL)



    let testString = "My contact number is: 1243233423"

//loading the html string using javascript.

    let stringToBeLoaded = "var text=\"\(testString)\";showText(text);        //showText() is a method in the index.html file to set the content.

    webview.evaluateJavaScript(stringToBeLoaded, completionHandler: nil)          //Doing this way is not detecting the phone number

//loading the html string

    webview.loadHTMLString(testString, baseURL: nil)          //Doing this way is identifying the phone number and converting it to a clickable link from which I can call to this number.
over 4 years ago · Santiago Trujillo
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