簡體   English   中英

建立一個鏈接,如果已安裝,則打開應用程序;如果未安裝,則打開Goog​​le Play / Appstore;如果是台式機,則打開另一個鏈接?

[英]Make a link that opens app if installed, open Google Play/Appstore if not installed, and open another link if desktop pc?

我想在電子郵件中建立一個鏈接,該鏈接會打開我的應用程序(如果已安裝該應用程序)。 如果尚未安裝,我希望它根據用戶使用的電話來打開google play或Appstore。 如果它們在台式機上/除了android和IOS以外的其他任何設備,它都應該打開另一個普通的網絡鏈接。

這怎么可能?

首先檢測用戶代理,然后根據該用戶將用戶導航到不同的位置。 這是簡單的javascript代碼,您可以將其添加到您的網站中,然后在電子郵件中提供網站網址。 希望能有所幫助。

//Useragent detection from http://stackoverflow.com/questions/21741841/detecting-ios-android-operating-system
        function getMobileOperatingSystem() {
          var userAgent = navigator.userAgent || navigator.vendor || window.opera;

              // Windows Phone must come first because its UA also contains "Android"
            if (/windows phone/i.test(userAgent)) {
                //Code here for windows phone.
            }

            if (/android/i.test(userAgent)) {
                window.location = 'https://play.google.com/store/apps/details?id=YOUR_APPLICTION_ID';
            }

            // iOS detection from: http://stackoverflow.com/a/9039885/177710
            if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
               //Code here for itunes. 
            }

           //Code to navigation for your website.
        }

在Android中打開應用需要在android中實現特定的URI,然后您可以將用戶重定向到該URI,以打開您的應用。

暫無
暫無

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

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