简体   繁体   English

Vuejs - 检查是否安装了移动应用程序

[英]Vuejs - Check if mobile application is installed or not

I'm working on a web application.我正在开发一个 Web 应用程序。 Where I've placed a check to determine whether the link is opened on a mobile device or a laptop.我在哪里检查过链接是在移动设备还是笔记本电脑上打开的。

consider the link to be: my-site.com

Now my site also has a mobile application on android and ios.现在我的网站在 android 和 ios 上也有一个移动应用程序。 If the android app is installed and I click a button called "Start" it opens that link in the mobile app.如果安装了 android 应用程序并且我单击了一个名为“开始”的按钮,它会在移动应用程序中打开该链接。

What I want to achieve:我想要达到的目标:

What I want to achieve is if the android app is not installed and the "Start" button is clicked then it should open the playstore link for the app and if it is installed the button takes to the app.我想要实现的是,如果未安装 android 应用程序并单击“开始”按钮,则它应该打开该应用程序的 Playstore 链接,如果安装了该按钮,该按钮将转到该应用程序。

Current Approach:当前方法:

I've placed checks for device=mobile and where the device is android open the android app and where the device is ios open ios link but how to open playstore/app store if app is not installed.我已经检查了 device=mobile 和设备是 android 打开 android 应用程序和设备是 ios 打开 ios 链接的位置,但是如果未安装应用程序,如何打开 Playstore/应用程序商店。

you can check the userAgent of the browser and add a link to the playstore.您可以检查浏览器的 userAgent 并添加到 Playstore 的链接。 If the app is installed it will open the app if not the playstore of the native device will be opened.如果安装了该应用程序,它将打开该应用程序,否则将打开本机设备的 Playstore。

add this functionality to the click event of the button:将此功能添加到按钮的点击事件中:

...
         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';
     }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM