Re: [whatwg] Persistent state for homescreen web apps (without reloading each time)

On Mon, Jun 8, 2015 at 8:10 PM, Zac Spitzer <zac.spitzer@gmail.com> wrote:

> Is it within the scope of the spec to specify whether home screen web apps
> should
> retain their loaded state when switching from foreground to background and
> back to foreground again?
>
> Chrome behaves exactly as expected, however, iOS reloads the web app each
> time
>
>
> http://zacster.blogspot.com.au/2015/04/broken-web-apps-launched-from-ios-home.html


If you want to more reliably store state, for home screen app bookmarks as
well as for regular web pages, take a look at the history API.  That gives
the browser a clear, self-contained block of data to store and restore,
unlike the state of the page itself which isn't always possible to restore
cleanly.  The History API also means that state can be cleanly restored
after browser forward/back, even across session restarts.

I seem to recall this works on iOS for homescreen apps, but it's been a
while since I've tested it.  It'll definitely store the URL (so you can
encode state in the hash, as usual), but you should be able to store data
using the "data" argument as well, for more complex persisted state.

-- 
Glenn Maynard

Received on Tuesday, 9 June 2015 20:17:43 UTC