2015-07-20 137 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不能正确渲染屏幕。我有几个空白屏幕,正确的深度链接。在这种情况下,尝试再次执行相同的深度链接。它为我工作。