【问题标题】:Vuejs - Check if mobile application is installed or notVuejs - 检查是否安装了移动应用程序
【发布时间】:2020-01-23 10:43:38
【问题描述】:

我正在开发一个网络应用程序。我在哪里进行了检查以确定链接是在移动设备还是笔记本电脑上打开的。

consider the link to be: my-site.com

现在我的网站也有一个适用于 android 和 ios 的移动应用程序。如果安装了 android 应用程序并且我单击了一个名为“开始”的按钮,它会在移动应用程序中打开该链接。

我想要达到的目标:

我想要实现的是,如果未安装 android 应用程序并且单击“开始”按钮,那么它应该打开应用程序的 playstore 链接,如果已安装,则该按钮将进入应用程序。

目前的方法:

我已经检查了 device=mobile 和设备在哪里 android 打开 android 应用程序和设备在哪里 ios 打开 ios 链接但是如果未安装应用程序如何打开 playstore/app store。

【问题讨论】:

    标签: javascript android vue.js conditional-statements


    【解决方案1】:

    您可以检查浏览器的 userAgent 并添加指向 playstore 的链接。如果安装了应用程序,它将打开应用程序,否则将打开本机设备的 Playstore。

    将此功能添加到按钮的点击事件中:

    ...
             if(navigator.userAgent.toLowerCase().indexOf("android") > -1){
                 window.location.href = 
               'http://play.google.com/store/apps/details?id=PACKAGEURL';
         }
             if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){
                 window.location.href = 
           'http://itunes.apple.com/lb/app/PACKAGEURL';
         }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-16
      • 2011-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-23
      相关资源
      最近更新 更多