簡體   English   中英

Vuejs - 檢查是否安裝了移動應用程序

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

我正在開發一個 Web 應用程序。 我在哪里檢查過鏈接是在移動設備還是筆記本電腦上打開的。

consider the link to be: my-site.com

現在我的網站在 android 和 ios 上也有一個移動應用程序。 如果安裝了 android 應用程序並且我單擊了一個名為“開始”的按鈕,它會在移動應用程序中打開該鏈接。

我想要達到的目標:

我想要實現的是,如果未安裝 android 應用程序並單擊“開始”按鈕,則它應該打開該應用程序的 Playstore 鏈接,如果安裝了該按鈕,該按鈕將轉到該應用程序。

當前方法:

我已經檢查了 device=mobile 和設備是 android 打開 android 應用程序和設備是 ios 打開 ios 鏈接的位置,但是如果未安裝應用程序,如何打開 Playstore/應用程序商店。

您可以檢查瀏覽器的 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';
     }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM