在iOS中进入后台后,每次都会初始化PWA应用程序 [英] PWA Application is initialized every time after going background in iOS

查看:170
本文介绍了在iOS中进入后台后,每次都会初始化PWA应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试PWA应用程序.

I'm now testing PWA application.

在Android中,它运作良好. 即使进入后台,PWA应用程序仍保持状态,用户可以继续体验.

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

但是在iOS中,每次PWA应用程序进入后台后,都会对其进行初始化,并且像重新加载一样会破坏所有条件. 用户体验已终止.

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.

如何在iOS中防止这种情况?

How can I prevent this in iOS?

推荐答案

更新:使用最新版本的iOS(我已经用12.4测试过),PWA状态得以保留.感谢Leox和Roshil用另一个版本确认了这一点.

Update : With the latest version of iOS(I've tested with 12.4), PWA state is preserved. Thanks to Leox and Roshil on confirming the same with another version.

处理旧版iOS/Safari的原始答案:

如本文所述,iOS仍无法保留会话之间的PWA应用程序状态:(由于对服务工作者的首次正式支持是在iOS的前一周(2018年3月下旬)才出现的,因此我们可以期待看到更多功能,例如保留将来的状态.

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 .

我们暂时不走运.

您还可以在链接的文章中看到"Android和iOS在PWA方面的当前差距"中的"PWA在Android而非iOS上可以执行的操作"部分.

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.

作为一种解决方法,您可以在IndexDB中保持应用程序的状态(当前页面,用户填充的数据,可能的滚动开始)的状态,并在重新打开应用程序时可以读取该内容以将其还原.它适用于几乎大多数用例.

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.

这篇关于在iOS中进入后台后,每次都会初始化PWA应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆