Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

458
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda