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

459
Visualizações
How to intercept a fetch request from javascript in iOS wkWebView (using objective-c)

I have an hybrid app that runs on Android, and uses webView.
In javascript, I make a fetch request call, which is intercepted in webView via shouldInterceptRequest.

I am trying to achieve the same with iOS which uses wkWebView (the language is objective c).
In javascript, I make the same fetch request call, but it is not intercepted in wkWebView.

I added functions based on several links such as this Specifically, I added functions like:

  • createWebViewWithConfiguration
  • decidePolicyForNavigationResponse
  • startURLSchemeTask

For example:

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction preferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler  API_AVAILABLE(ios(13.0)){
...
}

But these functions are never reached, when I call fetch from my javascript code. I read here that wkwebview can intercept xhr request (if not fetch) but this is in swift which I don't understand.

How can iOS intercept fetch requests?

Thanks

p.s. I see posts for this questions and partial explanations that I don't fully understand. A Github example would be helpful but I have not found one so far...

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