Home » Android » android – Has anyone got Firebase app indexing to work?

android – Has anyone got Firebase app indexing to work?

Posted by: admin April 23, 2020 Leave a comment

Questions:

After the implementation, I am able to successfully confirm that Google Bot can index my app through Android Studio testing (Tools > Android > Google App Indexing Test). And per Google Search Console, over 200 pages of my app have been indexed. But here follow the problems

If the app is installed, then clicking on a Google Search result will open the app. But if the app is not installed, it goes to the website (i.e. no install button in search results).

Everything else with Firebase works: app invite, deep linking, analytics.

So I am asking, has anyone out there actually gotten Firebase App Indexing to work? And if so, how REALLY?

My app is one Activity with a Spinner where users choose content by selecting an item from the spinner. And a Fragment is populated when the user makes a choice. And of course to index, I call AppIndex.AppIndexApi.start(client, getAction()) when the Fragment is populated and I call AppIndex.AppIndexApi.end(client, getAction()) when the user chooses a different content… and repeat start-end.

Also instead of using Digital Asset Links I am associating my app with my website through the Search Console.

How to&Answers:

Few things:

Fetch as Google always fails.
Firebase app indexing test fails.

You might need to check robots.txt for your website to not prevent Google bots to crawl your APIs.

If the app is installed, then clicking on a Google Search result will open the app. But if the app is not installed, it goes to the website (i.e. no install button in search results).

To achieve the app installation flow shown in the following screenshot, you actually need to implement Web App Manifest on your site.

Answer:

I have implemented App indexing in my project.First few days it was not showing any install button.Try including your website link as a Property in search console plus app package name as property in search console

https://productforums.google.com/forum/#!topic/webmasters/Mqo_GOJO2pE link for similar problem.

Answer:

Needed packages and classes

import com.google.firebase.appindexing.Action;
import com.google.firebase.appindexing.FirebaseUserActions;
import com.google.firebase.appindexing.FirebaseAppIndex;
import com.google.firebase.appindexing.Indexable;
import com.google.firebase.appindexing.builders.Actions;

String TITLE = "your screen title";
static Uri BASE_URL = "your site uri";
String webPath = "application route";
String APP_URI =  BASE_URL.buildUpon().appendPath(webPath).build().toString();
Indexable indexPage = new Indexable.Builder().setName(TITLE).setUrl(APP_URI).build();
FirebaseAppIndex.getInstance().update(indexPage);
FirebaseUserActions.getInstance().start(Actions.newView(TITLE, APP_URI)); // call on opening the view
FirebaseUserActions.getInstance().end(Actions.newView(TITLE, APP_URI)); // call on closing the view

now your app screens will be indexed and open through url’s
add the below lines in the web app/ html pages

<meta property="al:android:url" content="" />
<meta property="al:android:app_name" content="" />
<meta property="al:android:package" content="" />
<meta property="al:web:url" content="" />
<link rel="alternate" href="" />