Stop reloading of web app launched from iPhone Home Screen

前端 未结 4 2033
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-22 20:04

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.

H

4条回答
  •  时光取名叫无心
    2020-12-22 20:20

    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. :-)

提交回复
热议问题