Nirbhay Kundan
Nirbhay Kundan

Reputation: 389

Sniff and modify URL requests coming from UIWebViewController

I have one html page open inside UiWebViewController with cordova. While index.html loading inside the Uiwebviewcontroller can we sniff the requests that is originating from index.html?

for example I have following html that is getting opened in UiWebviewcontroller:

<html>
<head>
   <link rel="stylesheet" type="text/css" href="theme.css">
    <script src="app.js"></script>
</head>
<body>
   <img src="img.jpg"/>
</body>
</html>

Can I sniff and modify the url that is getting requested inside Uiwebviewcontroller ie. img.jpg,theme.css,app.js to something like content/img.jpg, css/theme.css, js/app.js using Objective-C.

Upvotes: 2

Views: 438

Answers (1)

zoul
zoul

Reputation: 104075

Yes, that’s possible using NSURLProtocol, see this blog post by NSHipster and this related Stack Overflow thread.

Upvotes: 1

Related Questions