javascript - 如何检查应用程序是否已安装或未使用JavaScript

标签 javascript android html google-play

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

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

 <!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 - 如何检查应用程序是否已安装或未使用JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55946781/

相关文章:

javascript - 如何发送没有表单标签的输入文件?

javascript - 在我网站的图像上添加 Instagram 滤镜

python - 在 Python 中发送带有片段标识符的 GET 请求

javascript - 创建不滚动的元素

javascript - Ember Array 调用 get 就返回 findBy 返回未定义

javascript - 带有 [ngmodel] 的 Angular Material 2 日期选择器

java - Android 上的 Google 联系人 API

java - Android 应用程序滑动 viewpager 和滚动 recyclerview 非常慢,如何查明原因?

java - 如何在我的 Android Studio 项目中实现固定版本的库?

javascript - 在 jQuery 中转义撇号