• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

401
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...

almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error