2017-06-01 183 views
0

當用戶按下郵件鏈接,然後如何在iPhone中打開已安裝的應用程序,如果沒有安裝,那麼如何重定向到應用商店鏈接?從郵件鏈接打開iOS應用

回答

4

添加以下行到你的plist文件:(DemoTest是我的自定義URL方案)

<key>CFBundleURLTypes</key> 
    <array> 
     <dict> 
      <key>CFBundleURLName</key> 
      <string>DemoTest</string> 
      <key>CFBundleURLSchemes</key> 
      <array> 
       <string>DemoTest</string> 
      </array> 
     </dict> 
    </array> 

然後嘗試打開DemoTest://從瀏覽器的URL,它會問你打開安裝該應用程序。

enter image description here

HTML代碼:

<html> 
    <body> 
     <script type="text/javascript"> 
      window.onload = function() { 
       // Deep link to your app goes here 
       document.getElementById("l").src = "DemoTest://"; 

       setTimeout(function() { 
        // Link to the App Store should go here -- only fires if deep link fails     
        window.location = "https://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8"; 
       }, 500); 
      }; 
     </script> 
     <iframe id="l" width="1" height="1" style="visibility:hidden"></iframe> 
    </body> 
</html> 
+0

出於好奇:這應該直接從郵件打開應用程序,對吧?或者它會一直打開Safari,然後轉換到應用程序? – LinusGeffarth

+0

它會首先重定向到safari,然後「DemoTest://」URL檢查是否安裝了應用程序。 –

+0

@LinusGeffarth這裏是HTML代碼: –

相關問題