Search code examples
iphoneweb-applicationsmobile-safari

iphone safari web app backgrounding


I'm developing an iPhone web app following some of the suggestions that can be found here : http://matt.might.net/articles/how-to-native-iphone-ipad-apps-in-javascript/. In particular, I have designed it to open in a full screen window without the Safari address bar using

<meta name="apple-mobile-web-app-capable" content="yes" />.

On my own iPhone 4, when I test this is produces odd behavior. Unlike other apps and Safari, when I move away from this app it doesn't background; it doesn't save the execution state. It just loses everything. If I switch to something else on my phone and then come back to my web app, it launches it again fresh. So, here are some individual questions that make up my confusion:

1) Is this standard behavior or something weird that is happening on my phone? That is, if you have specific knowledge about the iPhone and know that this shouldn't happen, I'd be interested to know. Otherwise,

2) Can anything be done to change this? Can I make it save the current state in the same way that it does within Safari?

The Safari developer documentation is strangely silent on this.


Solution

  • This is a standart behaviour. as mentioned here: Prevent web app restart on iPad task switch You have to save the state into localStorage and check it on start up and fake the state.