5

因此,我期望在一些新的應用程序中實現應用程序鏈接,並且通過開發筆記非常詳細地閱讀,設置服務器,使用正確的json標題添加文件以及構建了一個測試應用。 Android M中引入的應用程序深層鏈接似乎正在工作,如果我給自己發送附帶鏈接的電子郵件,但是當我在Chrome的示例頁面上執行此操作時,它只是重新加載頁面。我只是打在我的網絡服務器上的根頁面。 (https://www.EXAMPLE.com)。我最初在我的平板電腦上遇到了Chrome的一些證書問題,但是我添加了根證書,現在它變成了綠色Android M - 應用程序鏈接在Chrome中不起作用

我正在使用Nexus 7 2013,剛刷新並運行Android M和Chrome,已更新。

我正在服務我的服務器上的HTML文件(就像它會如果我有一個後退頁)。

任何想法,如果這是我如何使用網頁/後退,或者如果我配置了錯誤的東西。它在Gmail中非常漂亮,沒有任務選擇器,但不在Chrome中。

我試着混合了幾個例子html看起來像這樣,沒有工作。

<a href="EXAMPLE://">Click HERE for schema</a> 

<a href="https://www.EXAMPLE.com/">Click HERE for url with slash</a> 

<a href="https://www.EXAMPLE.com">Click HERE for url, no slash</a> 

<a href="#" onclick="window.location('https://www.EXAMPLE.com/')">Trying with onclick javascript</a> 

我的Android清單:

<activity 
     android:name=".deepActivity" 
     android:label="@string/title_activity_deep" > 
     <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="www.EXAMPLE.com" /> 
      <data android:scheme="https" android:host="www.MYDOMAIN.com" /> 

      <!-- note that the leading "/" is required for pathPrefix--> 
      <!-- Accepts URIs that begin with "example://gizmos」--> 

     </intent-filter> 

https://developer.android.com/training/app-links/index.html

編輯:用以下命令

我一直在測試的自動驗證:

adb shell dumpsys package d | grep DOMAIN -ab5 

,我得到的結果:

230: Package: com.DOMAIN.deeplinkingtest 
275: Domains: www.DOMAIN.com 
308- Status: undefined 

從文檔

顯示當前的連接處理設置爲這個應用程序。已通過驗證且其清單包含android:autoVerify =「true」的應用程序顯示始終狀態。此狀態之後的十六進制數字與Android系統的用戶應用程序鏈接首選項記錄相關。該值不表示驗證是否成功。

回答

0

在您的網站中添加HTML標記如下。 <a href="http://domain.com" data-applink="domain.com">Link</a>

AndroidManifest.xml中

`

<intent-filter> 
    <action android:name="android.intent.action.MAIN" /> 
    <category android:name="android.intent.category.LAUNCHER" /> 
</intent-filter> 

<intent-filter>     
    <data android:scheme="http" />  
    <!-- or you can use deep linking like -->    

    <data android:scheme="http" android:host="domain.com"/> 
    <action android:name="android.intent.action.VIEW"/> 
    <category android:name="android.intent.category.BROWSABLE"/> 
    <category android:name="android.intent.category.DEFAULT"/> 

</intent-filter> 

`

+0

我試圖添加data-applink,這看起來liek它的JQuery擴展雖然?我嘗試了許多不同的變體,無論是否使用www。在域名中,無論是否帶有尾部斜槓,在HTML和清單中,但Chrome仍然沒有。 –

0

...但是當我做在鍍鉻的樣本頁面上,它只是重新加載 頁

我假設你的意思是你剛剛進入Chrome並在瀏覽器欄中輸入https://example.com

不幸的是,如果您在瀏覽器欄中鍵入URL,應用程序鏈接將不起作用。這聽起來可能令人沮喪,但有一個很好的理由,爲什麼這不應該工作。正如保羅Kinlan,谷歌開發倡導者解釋說這將是一個不好的用戶體驗:如果用戶輸入一個URL到系統的地址欄中

,那麼 意向的用戶是訪問相關頁面。我們不會 相信用戶打算去應用程序。 Ergo將 用戶重定向到應用程序是一種糟糕的用戶體驗。

link

這個答案只涉及到鍵入URL到瀏覽器地址欄。但是,如果用戶單擊網頁中的鏈接,則同樣(大部分)也適用。讓我們來解釋爲什麼事情不適用於每個示例鏈接。我將與中間的兩個啓動:

<a href="https://www.EXAMPLE.com/">Click HERE for url with slash</a>

<a href="https://www.EXAMPLE.com">Click HERE for url, no slash</a>

這些鏈接來啓動應用程序,瀏覽器將不得不意圖發送到系統action.VIEWcategory.DEFAULT **,category.BROWSABLE,並計劃httphttps。您可以創建一個意圖過濾器,將抓住這個意圖(您的應用程序鏈接意圖過濾器將工作):

<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"/> 
    <data android:scheme="https"/> 
    <data android:host="www.example.com"/> 
</intent-filter> 

如果您檢查日誌(或只是測試它,你有),可以看出,Chrome不發射一個意圖。他們選擇在內部處理該鏈接(通過導航到新頁面)。這是Chrome的功能,而不是Android。沒有辦法改變這一點。不過,您可以在Chrome會尊重的網址中指定自定義方案。這使我想到你的第一個網址:

<a href="EXAMPLE://">Click HERE for schema</a>

Chrome將就該計劃在這個URL和斷火的意圖:action.VIEWcategory.DEFAULT **,category.BROWSABLE,並計劃EXAMPLE。根據您的意圖篩選器設置,這將啓動您的應用程序。你的第一反應可能是對EXAMPLE方案添加到您的應用程序鏈接意圖過濾器:

<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"/> 
    <data android:scheme="https"/> 
    <data android:scheme="EXAMPLE"/> 
    <data android:host="www.example.com"/> 
</intent-filter> 

這將允許你點擊Chrome瀏覽器中的一個鏈接,讓Chrome在打開的應用程序。不過它現在會中斷應用鏈接。親的解決辦法是讓你的應用程序鏈接意圖過濾器不變,並添加第二個意圖過濾器能吸引您的自定義方案:

<!-- EXAMPLE scheme intent filter --> 
<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="EXAMPLE"/> 
    <data android:host="www.example.com"/> 
</intent-filter> 

<!-- App Linking 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:scheme="http"/> 
    <data android:scheme="https"/> 
    <data android:host="www.example.com"/> 
</intent-filter> 

這可能是TMI,但得到的根能理解爲什麼一切正常/不工作。

**請記住系統會將category.DEFAULT添加到任何隱含的意圖。

============================================

更新: 我應該補充說,使用你自己的方案是不好的做法。一個完全更好的方法是記錄here

相關問題