iPhone的浏览器:检查是否iPhone应用程序从浏览器安装 [英] iPhone browser: Checking if iPhone app is installed from browser

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

问题描述

我有网页,在那里我有按钮,要么打开的应用程序(如果已安装),或者如果未安装应用程序引导到应用商店。
它所有的工作,如果已安装应用程序(我称之为为MYAPP://)。但是,如果没有安装Safari浏览器的应用程序显示错误消息无法打开URL,仅此而已。有没有办法从JScript中禁用的消息或有另一种方式,从JScript中找出是否安装的应用程序(而不是打应用的网址)?

要主持人:我看到有人问<一个href=\"http://stackoverflow.com/questions/7535354/iphone-customer-url-scheme-from-browser-what-if-app-isnt-installed\">similar问题以及主持人错误地将其标记为重复。请您理解,问题是具体有关从浏览器这样做。

有所发现合适的解决方案<一href=\"http://stackoverflow.com/questions/1108693/is-it-possible-to-register-a-httpdomain-based-url-scheme-for-iphone-apps-like-y\">here

顺便说一句,如果有人感兴趣的是如何做同样的事情为Android,这里是code。我们使用Dojo库:

  dojo.io.iframe.send({
    网址:yourApp://富/酒吧
    载:函数(RESP){
      //无关,因为它会自动地打开应用程序
    },
    错误:函数(){
      window.location的=选择Android市场;
    }
  });


解决方案

目前我们使用code的形式分公司below--注意,IFRAME适用于更多的浏览器。只需在您的应用程序的URI和你的App Store链接代替。顺便说一句,使用的iframe,如果没有安装这些应用程序的沉默错误。这是伟大的!

 &LT;!DOCTYPE HTML&GT;
&LT; HTML和GT;
    &LT;身体GT;
        &LT;脚本类型=文/ JavaScript的&GT;
            在window.onload =函数(){
                //深层链接到您的应用程序放在这里
                。的document.getElementById(L)的src =my_app应用://;                的setTimeout(函数(){
                    如果深层链接失败时,才火灾 - //链接到App Store应该在这里
                    window.location的=htt​​ps://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8;
                },500);
            };
        &LT; / SCRIPT&GT;
        &LT; IFRAME ID =LWIDTH =1HEIGHT =1的风格=visibility:hidden的&GT;&LT; / IFRAME&GT;
    &LT; /身体GT;
&LT; / HTML&GT;

如果别人有更好的解决办法来检测URI方案调用是否真的失败了,请留言!我还没有见过,我已经花了很多时间去寻找。所有现有的解决方案仅仅依靠用户仍然是页面和setTimeout的射击上。

I have web page where I have Button that either opens app (if it installed) or directs to App store if app isn't installed. It all works if App is installed (I call into "MYAPP://"). However, if app is not installed Safari shows error message "Can not open URL" and that's it. Is there way to disable that message from JScript or is there another way to find out from JScript if app installed (instead of hitting app URL)?

To MODERATOR: I saw someone asked similar question and Moderator wrongly marked it as duplicate. Please understand that question was specifically about doing it from Browser.

Found somewhat suitable solution here

BTW if someone interested in how to do same thing for Android, here is code. We are using Dojo library:

  dojo.io.iframe.send({
    url: "yourApp://foo/bar",
    load: function(resp) {
      // nothing to do since it will automagically open App
    },
    error: function () {
      window.location = "go to Android market";
    }
  });

解决方案

At Branch we use a form of the code below--note that the iframe works on more browsers. Simply substitute in your app's URI and your App Store link. By the way, using the iframe silences the error if they don't have the app installed. It's great!

<!DOCTYPE html>
<html>
    <body>
        <script type="text/javascript">
            window.onload = function() {
                // Deep link to your app goes here
                document.getElementById("l").src = "my_app://";

                setTimeout(function() {
                    // Link to the App Store should go here -- only fires if deep link fails                
                    window.location = "https://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8";
                }, 500);
            };
        </script>
        <iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
    </body>
</html>

If others have better solutions to detect whether the URI scheme call actually failed, please post! I haven't seen one, and I've spent a ton of time looking. All existing solutions just rely on the user still being on the page and the setTimeout firing.

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

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