Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

442
Views
Cómo interceptar una solicitud GET ajax de javascript en iOS wkWebView (usando Objective-C)

Tengo una aplicación híbrida que se ejecuta en iOS y usa wkWebView (el lenguaje es el objetivo c ).
Estoy tratando de interceptar una solicitud GET desde el lado de javascript, en el lado wkWebView de iOS.
En javascript , realizo una llamada de solicitud fetch o xhr , pero no se intercepta en wkWebView .
(Una versión equivalente de la aplicación que se ejecuta en Android y usa webView funciona bien: la solicitud de búsqueda se intercepta en webView a través de shouldInterceptRequest ).

Si hago una llamada a window.location.href, la llamada se intercepta (en decidePolicyForNavigationAction) (pero esto no es una solicitud).
Pero si obtengo una solicitud xhr ( XMLHttpRequest ), la llamada NO se intercepta .

Varias preguntas en Internet como esta preguntan sobre cómo interceptar solicitudes POST.
Mi caso es aún más básico. No puedo interceptar una solicitud GET

Mi código se ve así:

Código JavaScript:

 let url = 'http://example.com'; // try3 - using href - call is intercepted in iOS (but this is not a request...) window.location.href = url; # -------------------------------------------------------------- // try2 - using xhr - call is NOT intercepted in iOS function makeRequest (method, url, done) { var xhr = new XMLHttpRequest(); xhr.open(method, url); xhr.onload = function () { done(null, xhr.response); }; xhr.onerror = function () { done(xhr.response); }; xhr.send(); } makeRequest('GET', url, function (err, datums) { if (err) { throw err; } console.log(datums); }); # -------------------------------------------------------------- // try1 - using fetch - call is NOT intercepted in iOS response = await fetch(url);

código nativo de Objective-C:

 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { DTLogDebug (@"BEG decidePolicyForNavigationAction"); ...

¿Cómo puede iOS interceptar las solicitudes xhr ajax?

Gracias

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!