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

455
Views
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
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!