Understanding Spotlight best practices and rating

If you implement Spotlight indexing in your app, it's beneficial for both you and your users if you adhere to the best practices for doing so. Sticking with the best practices will positively affect your ratings and can ultimately drive more users to your app.

We'll cover four best practices that you should always implement if you're able to. Doing so will give your app great advantages over other apps. The following are the two aspects we'll cover:

  • Adding metadata to your web links
  • Registering as an indexing delegate

Adding metadata to your web links

In the next chapter, Chapter 14, Making the Web and Your App Meet through Universal Links, we'll cover universal links and how you should implement them in your application. Enabling Universal Links benefits your Spotlight search ranking and visibility because Spotlight can associate web resources that Apple's bot can crawl with the items you add to the Spotlight index. To associate Universal Links and your locally indexed items with each other, you should set the contentUrl that matches the web resource for a local item on your search attributes objects.

Doing this enables Apple to easily display your search results as public and it can even display your Universal Link in Safari's search results. This means that it will be even easier for your users to discover your app.

More importantly, if you associate a contentUrl with an indexed item, your app is shown even to people who don't have your app installed. That aspect alone should convince you to make sure that your app has online resources that mirror the public content in your app.

Once you've decided to add content URLs to your content, it's important that you add proper, structured metadata to your web pages. If your web page has well-formatted metadata available, Spotlight will index your app's contents even if you don't manually add it. This is because Apple continuously crawls the marketing and support URLs you advertise with in the App Store.

In order for Apple's bot to be able to discover the URLs your app can handle, it checks whether there is a Smart App Banner implemented in your app. The Smart App Banner is visible to people who visit your website. If they already have your app installed, the banner will prompt the user to view this content in your app. If you've added a URL to the banner that your app can handle, Apple's bot is able to discover this link and associates it with your app.

The second thing you should do is add metadata about the content. When we manually index content, you can set properties on your attributes set to represent your data. On the web, you can't create an attribute set so you need to embed the metadata in your page's HTML markup. If you're implementing Open Graph metadata, Apple is able to understand that. However, Apple recommends that you implement richer and more fine-grained data for your app.

To do this, it's recommended to implement metadata as specified in the schema.org standards. These standards provide definitions for a wide range of different entities. For instance, you can express a product rating, pricing, or a business address through definitions of these entities on schema.org.

If you've implemented metadata for your app, or if you want to make sure that Spotlight is able to index your contents, you can use Apple's verification tools for search. Go to https://search.developer.apple.com  to paste in your website's URL and verify that everything can be indexed as you expected.

Having a complete set of metadata positively impacts your rating. An obvious reason is that it's better because more information means more matches for a search query. However, a different reason is that if a user sees a search result that provides a lot of information at a glance, it's easier for them to decide whether or not a specific result is relevant to them.

This quick assessment of relevancy up front makes sure that whenever a user selects a result for your app, they know for sure that they want to interact with that item. Apple measures this form of engagement to ensure that results that are tapped often and drive longer engagements are pushed to the top.

Directly related to this is the concept of keyword stuffing. When optimizing for a search, it can be tempting to stuff a lot of keywords into your content. Doing this will not positively impact your ratings in Spotlight. The reasoning behind this is that keyword-stuffed results will often simply look like spam. The preview won't be a coherent preview of contents, but it will look as though somebody tried to put as many relevant words together as they could. A result that looks poor is less likely to be tapped by a user and will be pushed down in the rankings eventually.

If the users do end up tapping a keyword-stuffed item, it's unlikely that they will actually find what they were looking for. Often, this means that the user exits your app after just a couple of seconds, and this negatively impacts your results rating.

In other words, add as much metadata as you reasonably can but ensure that any data you add is relevant, true, and actually exists in your app. A good preview in Spotlight and a matching experience in your app is the best way to rank highly for Spotlight.

Registering as an indexing delegate

An item you index today might change over time. Some items you add to Spotlight could even have an expiration date if you've set the endDate property on the item attributes. Therefore, it's important that you register your app as an indexing delegate.

The indexing delegate is used for a single purpose: re-indexing contents. If you've added items that expire over time, Spotlight will ask you to index them again to make sure that the expiration date is still correct. The indexing delegate is also called in case something goes wrong with the index itself, for example, if all pieces of data are lost or if the search index becomes corrupted.

The indexing delegate has two required methods: searchableIndex(_:reindexAllSearchableItemsWithAcknowledgementHandler:) and searchableIndex(_:reindexSearchableItemsWithIdentifiers:acknowledgementHandler:). The first method is called if the index has been lost and everything should be indexed. It's up to you to figure out how to index your entire app. In the FamilyMovies app, this would probably mean fetching all family members and indexing them. You could use the favoriteMovies relationship to loop over all of the movies we have in the database and index them. Alternatively, you could query both entities separately and index them separately. The second method receives an array of identifiers that need to be indexed.

After you index the required items, you should call the acknowledgementHandler that your delegate method has received. This will make sure that Spotlight understands that you have successfully executed the tasks you needed to perform. To set the indexing delegate, you set this indexDelegate of the search index. For most apps, this is CSSearchableIndex.default().

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.182.179