Best practice for offline website in iOS

I am creating an application that requires downloading a lot of html5 content. In fact, it works similarly to the magazine applications that you see for the iPad, except for the use of images, it will use UIWebViews and HTML.

My question is what would be the best method to store this. I was thinking about a downloaded zip file, which is unpacked in the kit and contains html files, images, css, etc. Or puts all the html in the database and just downloads and puts images, css, videos, etc. bundle.

Some considerations:

Many links will be local to the device, but some will be on external sites.

I will need to do a full text search on all html content.

Content size will vary.

On the side of the note, I would like to be pointed in the right direction to set up paging using UIWebViews. Potentially many UIWebViews.

Thanks Brandon

+7
source share
3 answers

You can download the file first, which reflects the image structure of the website, css, htmls.

Then you analyze this file and download each file and save it in the document directory (you do not save it in the database because you can have large images and it will be slow, you can save their paths). Ask for local html again.

Edit: You can catch the request in the webView delegate and see if it is internal or external

WebView: shouldStartLoadWithRequest: navigationType: Sent before the start of loading the web view content.

  • (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest: (NSURLRequest *) navigationType request: (UIWebViewNavigationType) navigationType

Link to UIWebViewDelegate Protocol

+2
source

This question is quite easy to answer by looking at the first and best review book on HTML5 right now ... And its best part was published under the CC license.

http://diveintohtml5.ep.io/offline.html <is an entire chapter on web application caching and a great starting point for your application.

It's not complicated, and it's a cutting edge that's cooler than that.

If you are really serious about making this application work offline, you should not generalize it outside the link.

Although I have more resources that were at the bottom of this chapter

Standards:

Browser Provider Documentation:

Lessons and demos:

+5
source

I have not used it myself, but you can take a look at the ASIHTTPRequest ASIWebPageRequest class.

0
source

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


All Articles