13

您知道如何将 Web 应用程序添加到 iPhone 的主屏幕......现在我如何检测我的应用程序是否已添加到用户 iPhone 的主屏幕。

如果已添加,我如何启动存储在用户主屏幕上而不是 Safari 中的应用程序。

NOTE : its a web app simply bookmarked on the home screen of an iPhone - it is NOT a native app.

有任何想法吗 ?

4

1 回答 1

30

根据Safari Web Content Guide,您必须<meta name="apple-mobile-web-app-capable" content="yes" />在网页中设置以全屏模式呈现您的内容。

您还可以通过设置设置启动图像以使其看起来像本机应用程序<link rel="apple-touch-startup-image" href="/startup.png">

编辑(检测是否以全屏模式运行)

您可以在网页中添加一些 JS 代码来检测它是否以全屏模式运行:

<script type="text/javascript">
if ('standalone' in navigator && !navigator.standalone && (/iphone|ipod|ipad/gi).test(navigator.platform) && (/Safari/i).test(navigator.appVersion)) {
    __do something here__
}

有关这方面的更多信息,这个项目可能会很有趣。

于 2011-08-10T19:23:05.717 回答