If you have ever worked on a website, you must have heard something about SEO (Search Engine Optimization). More importantly, you will know that any website you create and publish is indexed by several search engines. All you have to do is make sure that you write semantic and structured HTML markup and any web spider will understand what your website is about and what parts of it are more important. Search engines, such as Google, have indexed billions of web pages based on their contents and semantic markup.
Apps tend to be a little less neatly structured, and crawling them is a lot harder if not impossible. There is no structured way to figure out what content is on screen and what this content means. Also, more importantly, a lot of content you'd want to index is only available to users who have logged in or created content of their own.
This is why Apple decided that the developers themselves probably know their app's contents best and should be in charge about how, when, and why a particular content is indexed. Even though this does put a little bit of manual burden on the developers, it gives them a huge advantage over the automatic indexing that's done on the web. Since developers are in control, they can decide precisely which content matters most to specific users. As you'll soon see, you can index content based on the screens your user visits, which means that you will just index those pages that your user may want to visit again.
Even more important than being in control is the ability to safely index private contents. The web is limited to indexing public contents. If you use online email software to check your inbox or if you have an online project management tool, you must rely on the internal search functions inside the web page for these tools. You won't find your emails or projects through a regular search query. With Spotlight indexing, your users can do just that: Search through their own content. Indexing private contents is secure because the data is not made available to other apps and you can't accidentally make one user's private data visible to other users due to the public indexing threshold mentioned earlier.
So how exactly do developers take control then? That's the question that will be answered next. We'll take a look at the following three different methods that Apple came up with to index app contents:
- NSUserActivity
- CSSearchableItem
- Universal Links