Intercept HTTP request from WebView on Windows Phone 8

Is there a way to intercept an HTTP request on Windows Phone 8?

I have a PhoneGap application that I would like to intercept some of the HTTP requests that WebView creates and returns my own responses. I intercept calls that request assets on a web server and return assets that can be created locally.

On Android, I can use shouldInterceptrequest

In iOS, I can use NSURLProtocol

From what I can say on Windows Phone 8, I can register my own scheme to run my application, but I cannot intercept HTTP requests. Is there something I'm missing?

+6
source share
2 answers

I do not think this is possible for Windows Phone 8.

However, Windows Phone 8.1 has new features: http://blogs.windows.com/buildingapps/2013/07/17/whats-new-in-webview-in-windows-8-1/

Take a look at the section: Running a Custom URI

The message is about Windows 8.1, but there is sample code for Windows Phone 8.1: http://code.msdn.microsoft.com/windowsapps/XAML-WebView-control-sample-58ad63f7/ (script 4).

0
source

Great question. I have not created a phonegap application, so I’m not sure if you can link to the WebBrowser object on your page. If you can, you can use the Web browser “Navigation” event to have a VERY limited look at the request. The argument NavigatingEventArgs contains the request Uri, but more about that. If there is a specific uri that you are looking for, you can always cancel the navigation and redirect the web browser to something else.

0
source

Source: https://habr.com/ru/post/974863/


All Articles