简体   繁体   English

应用索引“在应用中打开”不起作用

[英]App Indexing “Open in App” doesn't work

So, I was trying to implement app indexing to allow "Open in App" feature from google search (in Chrome app).所以,我试图实现应用程序索引以允许来自谷歌搜索(在 Chrome 应用程序中)的“在应用程序中打开”功能。

I've implemented the following sections from google docs https://developers.google.com/app-indexing/ :我已经从谷歌文档https://developers.google.com/app-indexing/实现了以下部分:

  1. Add Deep Linking to your App将深层链接添加到您的应用程序

    <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. Connect your App连接您的应用程序

    I've verified and approved the website from Webmaster and Play console.我已经通过网站站长和 Play 控制台验证并批准了该网站。

  3. Provide Deep Links提供深层链接

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

I've tried testing my link "android-app://com.MyApp.MyApp/http/dl.mysite.com/" in https://developers.google.com/app-indexing/webmasters/test and the link opens my app home page.我试过在https://developers.google.com/app-indexing/webmasters/test和链接中测试我的链接“android-app://com.MyApp.MyApp/http/dl.mysite.com/”打开我的应用主页。 However, the listing corresponding to my site in google search results (in Chrome app) has no "Open in App" function.但是,在谷歌搜索结果(Chrome 应用程序中)中与我的站点相对应的列表没有“在应用程序中打开”功能。

I'd like to have this "Open in App" function.我想要这个“在应用程序中打开”功能。 I'd appreciate any help.我很感激任何帮助。

Try this solution试试这个解决方案

<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>

Different behaviors in Open in App from browsers and other applications to my webView app 从浏览器和其他应用程序到我的 webView 应用程序在应用程序中打开的不同行为

android-app://... is a normal deep link and is different from App Indexing. android-app://...是一个普通的深层链接,与 App Indexing 不同。

App Indexing include http://... and https://... urls only! App Indexing 仅包括http://...https://...网址!

If you want App Indexing to work, What you need is a /.well-known/assetlinks.json as on website.如果你想让 App Indexing 工作,你需要的是/.well-known/assetlinks.json就像网站上的一样。

It's called Google/ Firebase App Indexing - https://firebase.google.com/docs/app-indexing它称为 Google/ Firebase App Indexing - https://firebase.google.com/docs/app-indexing

There is an App Links Assistant built into Android Studio that will help you generate the assetlinks.json file and test URLs among other useful things. Android Studio 中内置了一个App Links Assistant ,可帮助您生成assetlinks.json文件和测试 URL 以及其他有用的东西。

Answer to a similar question addresses this problem.对类似问题的回答解决了这个问题。

App Indexing Android - "<link>" in "<head>" doesn't work Android 应用索引 - “<head>”中的“<link>”不起作用

To quote, "It'll work only from google search results page. If your website is properly indexed and appears in google search results, check if exists in the website's page source in google's cached content: http://webcache.googleusercontent.com/search?q=cache:yourwebsite.com .引用,“它只能从谷歌搜索结果页面工作。如果您的网站被正确编入索引并出现在谷歌搜索结果中,请检查谷歌缓存内容中网站的页面源中是否存在: http : //webcache.googleusercontent.com /search?q=cache:yourwebsite.com

Also, you might need to move your apk to PRODUCTION if it's in BETA TESTING in Google Play Developer Console."此外,如果您的 apk 处于 Google Play Developer Console 的 BETA TESTING 中,您可能需要将其移至 PRODUCTION。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM