Skip to content
This repository was archived by the owner on Jul 22, 2020. It is now read-only.

Why use SWWebView?

Alastair Coote edited this page Oct 16, 2017 · 4 revisions

Why would I want to add this to my app?

Lots of apps (the lab works in news, so you can probably substitute "lots of news apps" there, but I do think some of this applies in other industries) use webviews to display content. It makes a lot of sense - articles often vary in display style, some have maps, some have image galleries, so on and so forth. Not only that, web pages can be updated on the server to reflect any new (i.e. breaking news) situation without having to adjust the app, submit for review and publish. But webviews don't come with things like caching built in - everyone has their own home-grown system for caching files in app storage and loading from the file:// protocol, or injecting HTML directly, or... well, some don't have caching at all. So...

Get rid of some of your code.

If you're manually maintaining caching code in your app, you could use this instead. That's not entirely fair though, because it doesn't magically cache for you, you will need to write some JavaScript to do that. But...

Service Workers are cross platform.

Your web site might not be a Progressive Web App yet, but the reasons not to make one are getting smaller and smaller. All the worker JavaScript you write for your app can be used on your web site too, bringing things like offline availability to a broader collection of users. In future versions, SWWebView will also handle notifications just like the web platform does, adding even more functionality you'll be able to port over.

More capable interactives

If you are in news and willing in indulge hyperbole: interactive features have historically been limited to what is possible in the browser - for example, having to wait until WebGL was implemented before being able to interesting 3D work. Things like the Notification API and Presentation API open up a lot of possibilities for interactive, and the intention is that SWWebView will eventually provide them in ways that will also work in browsers, letting you reach dedicated readers and the broader web audience at the same time.

Why would I not want to add this to my app?

Webviews are particularly suited to news content because, at their heart, news articles are documents. And web browsers were originally a tool for viewing documents. But if your app has a lot more doing than reading - forms, games, that sort of thing, you may well be better off with something like React Native. Or just use native - Swift is a lovely language, you know.