2016-10-10 101 views
0

我想在電子郵件中創建鏈接,該鏈接將打開我的應用,如果安裝了該應用。 如果沒有安裝,我希望它打開谷歌播放或Appstore取決於人們使用的電話。 如果他們在臺式電腦/其他任何東西比Android和IOS,它應該打開另一個正常的網絡鏈接。創建一個鏈接,打開應用程序,如果安裝,打開谷歌播放/應用程序,如果沒有安裝,並打開另一個鏈接,如果臺式電腦?

這怎麼可能?

+0

這可能會幫助你http://stackoverflow.com/questions/34942269/downloadmanager-illegalstateexception-creating-a-download-in-directory-downloads/34942270#34942270 –

+0

我建議你使用2個不同的按鈕,他玩商店和appstore。所以你不需要撥動外部網絡來檢測消費者使用的設備 – Niqql

回答

0

首先檢測用戶代理,然後根據該用戶導航到不同的位置。這裏是您可以在您的網站中添加的簡單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來打開應用程序。

+0

問題是,它是用於HTML電子郵件,所以Javascript可能不是一種可能性? – Nikolai907

+0

創建一個簡單的頁面來保存該javascript,使用href在html中將用戶重定向到該頁面。從那裏你可以決定它是哪個用戶代理。 – Aimanzaki

相關問題