iPhone Safari Web 应用程序背景
我正在开发一个 iPhone Web 应用程序,遵循以下建议:http://matt.might.net/articles/how-to-native-iphone-ipad-apps-in-javascript/。特别是,我将其设计为在我自己的 iPhone 4 上使用没有 Safari 地址栏的全屏窗口打开
<meta name="apple-mobile-web-app-capable" content="yes" />.
,当我测试时会产生奇怪的行为。与其他应用程序和 Safari 不同,当我离开此应用程序时,它不会进入后台;它不保存执行状态。它只会失去一切。如果我切换到手机上的其他内容,然后返回我的网络应用程序,它会再次重新启动它。因此,以下是一些让我感到困惑的个人问题:
1)这是标准行为还是我的手机上发生了奇怪的事情?也就是说,如果您对 iPhone 有具体了解并且知道这种情况不应该发生,我很想知道。否则,
2)可以采取什么措施来改变这一点吗?我可以让它像在 Safari 中一样保存当前状态吗?
奇怪的是,Safari 开发者文档对此只字不提。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一种标准行为。
如此处所述: 防止 Web 应用程序在 iPad 任务切换上重新启动 您必须将状态保存到 localStorage 中并在启动时检查它并伪造状态。
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.
至少在 iOS 4.2.1、5.1.1、6.0 和 6.1 下,这似乎是可能的;我认为这个问题接受的答案是错误的。
诀窍是这样做:
有关此策略的更详细讨论,请查看 在 iPhone 上的网络应用程序中维护 PHP 会话
At least under iOS 4.2.1, 5.1.1, 6.0 and 6.1, this does seem possible; I think the answer accepted for this question is wrong.
The trick is to do this:
For a more elaborate discussion of this strategy, take a look at Maintain PHP Session in web app on iPhone