本文介绍了如何检查是否从 iPhone 上的网页安装了应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个网页,该网页会将 iPhone 重定向到 App Store 如果 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 存在丑陋的 hack,我也很想知道.

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.

类似问题:

这篇关于如何检查是否从 iPhone 上的网页安装了应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 22:29