1

I know it's a long shot. if it was possible, it would probably be supported in PhoneGap, but Is it possible to intercept a synchronous AJAX request executed by JS code (in html file) running on a UIWebView, perform some native calls and edit the response? similar to what PhoneGap does, but synchronously not asynchronously (instead of having to chain async PhoneGap callbacks to "pyramids of death" or use Promises).

Maybe somehow using NSURLProtocol / NSURCLCache?

Alon Amir
  • 4,913
  • 9
  • 47
  • 86

1 Answers1

1

I had the exact same need : i wanted to catch AJAX request in objective-c and return some cached response to the javascript handler. I managed to get it working using a NSURLProtocol, you can see the full implementation here :

How to mock AJAX call with NSURLProtocol?

Community
  • 1
  • 1
vdaubry
  • 11,369
  • 7
  • 54
  • 76