应用索引 "Open in App" 不起作用

App Indexing "Open in App" doesn't work

因此,我尝试实施应用索引以允许 google 搜索中的 "Open in App" 功能(在 Chrome 应用中)。

我已经实现了 google 文档 https://developers.google.com/app-indexing/ 中的以下部分:

  1. 将深层链接添加到您的应用程序

    <activity
        android:name=".DeepLinkActivity">
        <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="http"
                android:host="dl.mysite.com"
                android:pathPattern="/" /> <!-- Home page -->
        </intent-filter>
    </activity>
    
  2. 连接您的应用程序

    我已经从网站站长和 Play 控制台验证并批准了该网站。

  3. 提供深层链接

    <link rel="alternate" href="android-app://com.MyApp.MyApp/http/dl.mysite.com/" />
    

我已经尝试在 https://developers.google.com/app-indexing/webmasters/test 中测试我的 link "android-app://com.MyApp.MyApp/http/dl.mysite.com/" 并且 link 打开了我的应用程序主页。 但是,google 搜索结果(在 Chrome 应用程序中)与我的站点对应的列表没有 "Open in App" 功能。

我想要这个 "Open in App" 功能。如果有任何帮助,我将不胜感激。

类似问题的答案解决了这个问题。

引用,“它仅适用于 google 搜索结果页面。如果您的网站已正确编入索引并出现在 google 搜索结果中,请检查该网站的页面源中是否存在google的缓存内容:http://webcache.googleusercontent.com/search?q=cache:yourwebsite.com.

此外,如果您的 apk 在 Google Play Developer Console 中处于 BETA 测试阶段,您可能需要将其移至生产版。

android-app://... 是一个普通的深度 link,与 App Indexing 不同。

App Indexing include http://... and https://... urls only!

如果您希望 App Indexing 正常工作, 您需要的是网站上的 /.well-known/assetlinks.json

它被称为 Google/ Firebase 应用索引 - https://firebase.google.com/docs/app-indexing

App Links Assistant 内置于 Android Studio 中,可帮助您生成 assetlinks.json 文件和测试 URL 以及其他有用的东西。

试试这个解决方案

<activity ... android:launchMode="singleTask">
[...]
<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:host="@string/domain"
                    android:scheme="https"
                    android:pathPattern=".*" />
                <data
                    android:host="@string/domain"
                    android:scheme="http"
                    android:pathPattern=".*" />
</intent-filter>