Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop reloading of web app launched from iPhone Home Screen

I created a web app and added to my iPhone Home Screen. When I switch to another app and back, iPhone automatically reload my web app. This breaks my app flow.

How do I prevent iPhone from reloading the app?

I have apple-mobile-web-app-capable meta tag enabled to hide Safari toolbar and I don't want to turn it off.

like image 634
Rand Avatar asked Aug 03 '11 17:08

Rand


People also ask

How do I stop apps from running on my home screen?

Find and tap Play Store. Drag the left edge of the screen to the right, then tap Settings. Uncheck the Add icon to Home screen checkbox.


1 Answers

I just found this related question on SO: Stop native web app from reloading itself upon opening on iOS

As it seems it's a limitation of Safari, a proposed solution is to persist your web apps state using Javascript and HTML5 localStorage. When your web app is launched, check for the persisted state and load it if available.

You can read about using localStorage in Safari here: http://developer.apple.com/library/safari/#documentation/iPhone/Conceptual/SafariJSDatabaseGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007256-CH1-SW1

Hope that helps you. At least it did for me, as I had the same problem as you. :-)

like image 171
René Avatar answered Sep 20 '22 03:09

René