2015-07-20 47 views
9

我們正在嘗試實施Google's App Indexing功能。我們已經添加了深層鏈接到我們的網站在以下格式REL-備用標記:在Deep Link中使用&符號進行索引編制索引

android-app://id.of.the.app/scheme/?screen=Product&product=123456 

現在,我們得到內容不相符抓取錯誤。如果我使用QR碼從here進行測試,一切正常。但是,如果我打開抓取錯誤,請單擊「打開應用程序頁面」並使用adb命令進行測試,我可以看到從&開始的所有內容都不會傳遞到應用程序,因此無法加載我的產品數據。我懷疑這是抓取程序如何檢查應用程序的內容,這就是我們得到內容不匹配錯誤的原因。

另外,如果我使用Search Console中的「Google抓取方式」,它看起來像從&符號中的所有內容都會被截斷。

我檢查易趣,因爲它正在與他們的應用程序,這就是他們所使用的鏈接:他們已經編碼的符號與&

android-app://com.ebay.mobile/ebay/link/?nav=item.view&id=221559043026&referrer=http%3A%2F%2Frover.ebay.com%2Froverns%2F1%2F711-13271-9788-0%3Fmpcl%3Dhttp%253A%252F%252Fwww.ebay.com%252Fitm%252FRoxy-Fairness-Backpack-Womens-Red-RPM6-%252F221559043026%253Fpt%253DLH_DefaultDomain_0 

,但如果我這樣做,並測試它的「取像谷歌「功能它也不起作用。

這些用戶似乎有同樣的問題,但他們不同意的解決方案(如果他們發現一個):

https://productforums.google.com/forum/#!msg/webmasters/5r7KdetlECY/enYknTVkYU4J https://productforums.google.com/forum/#!topic/webmasters/lswyXKlS-Ik

我很感激您的任何想法。

更新1

這就是我如何解釋的Android應用程序內部的深層鏈接:

Uri data = getIntent().getData(); 
String scheme = data.getScheme(); 
if (scheme.equals("scheme")) { 
    String screen = data.getQueryParameter("screen"); 
    if (screen.equals("Product")) { 
     String product = data.getQueryParameter("product"); 
     // Open Product and give it product number as intent data 
    } 
} 

更新2

下面是我們的Manifest.xml的相關部分:

<activity 
    android:name="id.of.the.app.StartActivity" 
    android:configChanges="orientation|screenSize" 
    android:label="@string/app_title" 
    android:windowSoftInputMode="adjustPan|stateHidden"> 

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

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

</activity> 
+0

你如何獲得&後面的內容? –

+0

我更新了我的問題,並添加了一些關於深度鏈接在android應用程序中的處理方式 –

+0

我沒有收到您的問題,我直接使用網頁和adb命令。你能分享你如何得到「抓取錯誤」嗎? –

回答

0

更新3
我還是想知道,如果它是有可能避免的變化,以清單和重新提交該應用。使用您發佈的AndroidManifest,您是否嘗試過更改rel-alternate標記以包含主機(如果它未包含在清單中,則爲事件)?例如,你有沒有嘗試android-app://id.of.the.app/scheme/fakehost/?screen=Product&product=123456 fakehost是一個字符串?我猜標籤的語法必須是android-app://{package_name}/{scheme}/{host_path},所以需要在網站上有一個主機(但可能不在應用程序上)。


更新2
後您發佈的清單,我想你錯過了你的意圖過濾器的數據標籤的強制性「主機」。

獲取此作爲參考:

<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="myapp" android:host="link"/> 
    <data android:scheme="myapp" android:host="link/"/> 
</intent-filter> 

和HTML元應該是(Android的應用程序://包名/方案/主機)

<html> 
<head> 
<link rel="alternate" 
     href="android-app://it.test.testdeeplink/myapp/link/?p1=1&p2=2" /> 
... 
</head> 

你可能需要更新你的應用程序,因爲你的Manifest將不得不被修復。


首先,感謝所有的澄清。我想對於深層鏈接(您正在實現的功能)和Chrome Intent(您提供的評論鏈接)存在一些困惑。因此,我決定實施一個小型項目,您可以通過我的dropbox folder進行下載。該項目非常簡單,並且有一項活動,可以通過Intent數據(當然,如果您通過應用程序啓動器啓動應用程序,您將看不到任何內容)每打印一行參數。該活動支持兩個意圖過濾器模式(MY-Android的應用程序和HTTP),並在MainActivity.java結束時,你可以找到(如評論)

  1. 一條線來測試深層鏈接對亞行和第一模式
  2. 一條線,用於測試對adb的深度鏈接,第二個模式
  3. 一個簡單的html頁面,用於使用瀏覽器測試深層鏈接 - 最後兩個href是由Chrome正確管理的Intent。

由於我沒有訪問您的代碼,我不能看看是否有任何問題,我想這是最好的方式來幫助你,並讓我的回答接受:)

+0

我很想獎勵你的努力,但它不能解決我的問題。我編輯了我的問題,試圖使其更清楚。我們正在實施App Indexing功能(請參閱答案中的鏈接)。它將您網站的內容鏈接到您的應用內的內容。如果發生這種情況,並且用戶在智能手機上搜索,搜索結果不再在瀏覽器中打開。它直接打開你的應用程序。爲此,Google需要知道他們如何才能訪問應用內的內容。這是通過rel-Tag完成的。但谷歌一直抱怨,內容不匹配,我不知道爲什麼... –

+0

更新了問題 –

+0

我還沒有測試任何它。問題在於我們網站上的更改需要大約一週的時間才能部署。即使他們只是改變一個簡單的鏈接標籤。我們試圖用jQuery來操作標籤,但這些更改不會被Google Crawler獲取。因爲你的答案看起來最有前途,所以我會給你賞金。如果以後是解決方案,我會接受你的答案。 –

0

嘗試用%26

的問題,以取代符號是錯誤的平臺工具版本21

+0

你能鏈接對這個'bug'的引用嗎? –

+0

https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=76026 – jlopez

+0

好的。似乎有一個錯誤,但我的問題不是使用adb命令打開了錯誤的頁面。我想擺脫Google在Search Console中給我的'內容不匹配'錯誤。 –

0

應用使用Uri中的查詢參數建立索引對我來說工作正常。請檢查您是否正確執行了所有步驟:

  • 聲明爲id.of.the.app.StartActivity計劃在AndroidManifest.xml

    <intent-filter> 
         <action android:name="android.intent.action.MAIN" /> 
         <category android:name="android.intent.category.LAUNCHER" /> 
        </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="my_custom_scheme"/> 
         </intent-filter> 
    

  • 解析深層連結

假設我們已經從命令行下面的深層鏈接my_custom_scheme://test_authority/product_screen/?product=123456&test_param=0000&utm_source=google&utm_medium=organic&utm_campaign=appindexing

public void parseDeeplikUrl(Uri uri) { 
     if (uri == null) { 
      // fallback: open home screen 
     } 
     String autority = uri.getAuthority(); 
     String path = uri.getPath(); 
     String query = uri.getQuery(); 

     // authority = "test_authority" 
     // path = "products_screen" 
     // query = "product=123456&test_param=0000&utm_source=google&utm_medium=organic&utm_campaign=appindexing" 
    } 
  • 測試應用程序索引:

    adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "my_custom_scheme://test_authority/product_screen/?product=123456&test_param=0000&utm_source=google&utm_medium=organic&utm_campaign=appindexing" -e android.intent.extra.REFERRER_NAME android-app://com.google.appcrawler/https/www.google.com id.of.the.app' 
    

使用此命令adb我們模擬GoogleBot電話。

  • 轉到"Fetch as Google"Search console並檢查是否GoogleBot工作也沒關係,並呈現正確的應用程序屏幕。

    android-app://id.of.the.app/my_custom_scheme/test_authority/product_screen/?product=123456&test_param=0000&utm_source=google&utm_medium=organic&utm_campaign=appindexing 
    

附::有時GoogleBot不能正確渲染屏幕。我有幾個空白屏幕,正確的深度鏈接。在這種情況下,嘗試再次執行相同的深度鏈接。它爲我工作。