如何检查应用程序是否已安装或未使用JavaScript [英] How to check app is installed or not using javascript

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

问题描述

我正在使用javascript检查是否已安装应用程序,如果已安装我的应用程序,我想打开我的应用程序,否则它将重定向到Play商店帐户.问题是即使我已经安装了应用程序,它也会重定向到Play商店

I am using javascript to check if app is installed or not, if my app installed i want to open my app or else it will redirect to play store account. the issue is that it is redirecting to play store even i already have app installed

这是我正在检查应用程序的.html文件

This is my .html file where i am checking for app

 <!DOCTYPE html>
<html>
    <body>
        <script type="text/javascript">
            window.onload = function() {
                // Deep link to your app goes here
                document.getElementById("l").src = "intent://sdf/SplashScreen#Intent;scheme=vsd;package=com.sdf.android.ff;end";

                setTimeout(function() {
                    // Link to the App Store should go here -- only fires if deep link fails                
                    window.location = "https://play.google.com/store/apps/details?id=com.sdf.android.dffd";
                }, 500);
            };
        </script>
        <iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
    </body>
</html>

推荐答案

通过这种方式解决

<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script>


var fallbackToStore = function() {
  window.location.replace('https://play.google.com/store/apps/details?id=packgename');
};
var openApp = function() {
  window.location.replace('intent://app/SplashScreen#Intent;scheme=app_;package=com.sdf.android.dsds;end');
};
var triggerAppOpen = function() {
  openApp();
  setTimeout(fallbackToStore, 700);
};

triggerAppOpen();

</script>
</head>
<body>

</body>

</html>

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

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