load local file in webview ios using http protocol. (Create Webview server in android and iOS)

1k Views Asked by At

Is there any way to create the server in android and iOS to run a web-view? I want to run a local HTML file in a web-view with a local-host URL.

I have already searched for this on the following links but could not find any solution.

GCDWebServer

local-http-server-for-ios

Supercharging the Android WebView

Hereby i am sharing the actual scenario :

1) Download ".zip" file from server and save it on application library directory for offline use.

2) ".zip" file contents html and javascript files. It works when the HTML page is simple. But if the HTML references something else, i.e. a JavaScript file also in the library directory (with an absolute path like ), it will fail to load.

3) I need to setup local server in my device, On application launch local server starts and upload the application library directory on local server and then load the content using local host. See below example

  • Using Library directory path

file:////Users/prince/Library/Developer/CoreSimulator/Devices/75EF3DD7-DFD1-4EDB-9A6B-9FBA60F4D98C/data/Containers/Data/Application/32F774B2-E811-4281-A37A-DC8A5183B7C8/Library/Application%20Support/adededfe6c1c7bd8b5d5adb19861b9e0/Responses/36b8f6a8d6f58d58f117856dc80b0d37/abc.html

  • Using localhost path

http://localhost:8080/Application%20Support/adededfe6c1c7bd8b5d5adb19861b9e0/Responses/36b8f6a8d6f58d58f117856dc80b0d37/abc.html

Does anyone know why this happens, and how to resolve the issue?

0

There are 0 best solutions below