如何检查iPhone上的网页是否安装了应用程序? [英] How to check if an app is installed from a web-page on an iPhone?

查看:180
本文介绍了如何检查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 an url for the application that is something like:

myapp://

如果这个网址无效,我希望页面重定向到应用商店。
这可能吗?

And if this url is invalid, I want the page to redirect to the app store. Is this possible at all?

如果我没有在手机上安装应用程序并在safari中写下myapp:// url,那么我get是一条错误消息。

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.

希望这会有所帮助!

类似的问题:

  • iPhone browser: Checking if iPhone app is installed from browser
  • Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps?

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆