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

smo*_*izs 11 iphone iphone-web-app homescreen iphone-standalone-web-app

你知道如何将一个网络应用程序添加到iPhone的主屏幕......现在我如何检测我的应用程序是否已添加到用户iPhone的主屏幕.

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

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

有任何想法吗 ?

til*_*ilo 28

根据Safari Web内容指南,您必须<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__
}
Run Code Online (Sandbox Code Playgroud)

有关这方面的更多信息,该项目可能会引起关注.

  • 你好!是的,这有助于.. 检测网页是否已添加到主屏幕!万分感谢。我想我可以解决这个问题。 (2认同)