检测iphone主屏幕上的应用程序

时间:2011-08-10 18:37:48

标签: iphone iphone-web-app homescreen iphone-standalone-web-app

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

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

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

任何想法?

1 个答案:

答案 0 :(得分:28)

根据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__
}

有关此问题的更多信息,this project可能会引起关注。