如何检查是否从iPhone的网页上安装了应用程序 [英] How can I check if an app is installed from a web-page on an iPhone
问题描述
我想创建一个网页,该页面会将iPhone重定向到应用程序存储,如果iPhone没有安装应用程序,但是如果iPhone已经安装了应用程序,我希望它打开该应用程序.
I want to create a web-page, a page that will redirect an iPhone to the App Store if the iPhone does not have the application installed, but if the iPhone has the app installed I want it to open the application.
我已经在iPhone应用程序中实现了自定义URL,因此该应用程序的URL类似于:
I have already implemented a custom URL in the iPhone application, so I have a URL for the application that is something like:
myapp://
如果此URL无效,我希望页面重定向到App Store.这有可能吗?
And if this URL is invalid, I want the page to redirect to the App Store. Is this possible at all?
如果我没有在手机上安装该应用程序,并在Safari中编写了myapp://URL,那么我得到的只是一条错误消息.
If I don't have the application installed on the phone and write the myapp:// URL in Safari, all I get is an error message.
即使有一个使用JavaScript的丑陋骇客,我也很想知道.
Even if there exists an ugly hack with JavaScript, I would really like to know.
推荐答案
据我所知,您无法从浏览器中检查是否已安装应用程序.
As far as I know you can not, from a browser, check if an app is installed or not.
但是您可以尝试将手机重定向到应用程序,如果没有任何反应,请将手机重定向到指定页面,如下所示:
But you can try redirecting the phone to the app, and if nothing happens redirect the phone to a specified page, like this:
setTimeout(function () { window.location = "https://itunes.apple.com/appdir"; }, 25);
window.location = "appname://";
如果第二行代码给出结果,则永远不会执行第一行.
If the second line of code gives a result then the first row is never executed.
类似的问题: