2017-10-11 164 views
2

工作,我增加了一個深層鏈接到我的Android應用程序是這樣的:Android。深層鏈接不與HTTP/HTTPS方案

當我點擊https://example.com我重定向到網站。

當我將android:scheme="https"更改爲android:scheme="appscheme"它可以工作,並將我重定向到我的應用程序。

如何強制我的應用程序通過https計劃打開?

UPDATE

我加了一個子域,它仍然不起作用。

<activity 
     android:name=".views.DeepLinkActivity" 
     android:exported="true"> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <data 
       android:scheme="https" 
       android:host="www.example.ru"/> 
     </intent-filter> 
    </activity> 
+1

是你的項目包example.com:

因此,通過改變你的意圖過濾器?否則用你的包名取代它也嘗試用此行替換主機android:host =「open」做這些都讓我知道 –

+0

如果我用「打開」替換主機它是如何知道我想從哪個站點重定向? – Rainmaker

+0

只要模式匹配 –

回答

1

嗨,請使用以下的數據,也嘗試參考此doc

<intent-filter> 
       <data 
        android:scheme="ou unique scheme(appname,package name)" /> 

       <action android:name="android.intent.action.VIEW" /> 
       <category android:name="android.intent.category.BROWSABLE" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 

OR

<data 
       android:scheme="you unique scheme(appname,package name)" 
       android:host="www.example.ru"/> 
0

試一下這個

<activity 
      android:name=".views.DeepLinkingActivity" 
     android:exported="true"> 


      <intent-filter android:autoVerify="true"> 
       <action android:name="android.intent.action.VIEW" /> 

       <category android:name="android.intent.category.DEFAULT" /> 
       <category android:name="android.intent.category.BROWSABLE" /> 

       <data 
        android:host="open" 
        android:scheme="example" /> 
      </intent-filter> 
      <intent-filter android:autoVerify="true"> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 

       <data 
        android:host="example.com" 
        android:pathPrefix="/" 
        android:scheme="http" /> 
      </intent-filter> 
      <intent-filter android:autoVerify="true"> 
       <action android:name="android.intent.action.VIEW" /> 

       <category android:name="android.intent.category.DEFAULT" /> 
       <category android:name="android.intent.category.BROWSABLE" /> 

       <data 
        android:host="example.com" 
        android:pathPrefix="/" 
        android:scheme="https" /> 
      </intent-filter> 
     </activity> 
+0

在Branch.io應用程序中定義「example://」模式 –

+0

但是如果我有https方案? – Rainmaker

+0

是的,我們在intent-filter中同時定義了https和http。它在我身邊 –

0

你指的深度鏈接,但android:autoVerify="true"用於應用程序的連接,因此域example.com(你不擁有?)是會得到檢查數字資產鏈接json文件。見https://developer.android.com/training/app-links/index.html

爲了您的測試工作,我建議刪除android:autoVerify="true"並添加一個子域的主機,例如, android:host="www.example.com"

+0

我將android:host =「example.com」更改爲android:host =「www.example.com」,刪除了autoVerify,但沒有結果,我錯過了什麼? – Rainmaker

+0

您是否也將可點擊鏈接更改爲「https:// www.example.com」? – veritas1

+0

現在它說連接不安全。順便說一下,我已經添加資產鏈接文件到服務器根據您的鏈接,但仍然沒有結果 – Rainmaker

0

只需使用http。不知道實施何時更改。

但我剛剛測試使用http將使http和https工作。

<intent-filter android:autoVerify="true"> 

<action android:name="android.intent.action.VIEW" /> 
<category android:name="android.intent.category.DEFAULT" /> 
<category android:name="android.intent.category.BROWSABLE" /> 

<data 
    android:scheme="http" 
    android:host="example.com"/> 

</intent-filter>