2017-08-25 45 views
0

我想通過下面的javascrip一段代碼實現深層鏈接,但問題是如果我在Android設備上安裝了應用程序,它在應用程序和Playstore網址上打開sametime.Any對此有何建議?深度鏈接開放Android和Playstore網址上安裝的應用程序

<html> 

<body> 
<button onclick="launchAndroidApp()">Deep linking test</button> 
<script> 
function launchAndroidApp() { 
      var test = window.open('DeeplinkingURL', "_self"); 
      setTimeout("window.location = 'Playstoreurl", 1000); 
    } 
    </script> 
    </body> 

    </html> 

回答

0

setTimeout方法簡單地被1秒後不管執行。這不是這樣做的正確方法,但如果你確信這種方法,我會嘗試使用try-catch。我想推薦使用Branch。你可以免費使用他們的SDK來做到這一點,並且更乾淨。

0

您可以使用Android Intents with Chrome的單個URL。例如,假設DeeplinkingUrl="https://example.com/hello",你期望它由com.example.Hello應用程序打開,

intent://example.com/hello 
    #Intent; 
    scheme=https; 
    package=com.example.Hello; 
    S.browser_fallback_url=market%3A%2F%2Fdetails%3Fid%3Dcom.example.Hello; 
    end 

不含空格,將使用com.example.Hello(如果可用)推出https://example.com/hello,並打開Play商店否則的應用列表。 (當然你可以用http://play.google.com/store/apps/details?id=代替market://details?id=。)

相關問題