PWA Application is initialized every time after go

2019-03-15 12:04发布

问题:

I'm now testing PWA application.

In Android, it works well. Even after going background, PWA app keep condition and user can continue their experience.

But in iOS, every time after PWA app goes background, it is initialized and every condition is crushed like it is reloaded. User experience is terminated.

How can I prevent this in iOS?

回答1:

As mentioned in this article, iOS still doesn't preserve the state of a PWA app between sessions :( Since the first official support for service workers came just a week before(Late March-2018) in iOS, we can expect to see more features such as preserving the state in the future .

We are out of luck for now.

You can also see "What PWAs can do on Android and not on iOS" section in the linked article on current gaps between android and iOS with respect to PWA.

Update : As a workaround, you can keep persisting the state of your application(current page, user filled data, scroll start if possible) in IndexDB and when the application is reopened you can read that to restore it. It works for pretty much most use cases.



回答2:

Now you can update your iOS to 12.2 beta 5 to hold the state of the PWA app after restored it from minimized state. Thanks to Apple!