There are thousands of new applications appearing on the App Store daily and even if the user has downloaded an app, it can easily be forgotten. As a solution to this problem, at Zalando, we use the App Indexing feature - making it more accessible and recognizable in search.
My name is Katrina Gridina, and I am a software engineer at Zalando in Berlin. In this talk, I’ll cover search on iOS. Spotlight is an under-utilized feature; at the moment only 60,000 of the applications in the App Store uses it.
An App search consists of three APIs: Core Spotlight API, NSUserActivity and Web Markup API.
Core Spotlight API
Core Spotlight API indexes private data even when it’s not visible. Only a local user on their own device can see its results in Spotlight for what was searched. When I see the results on Spotlight, instead of going to the website for that result, it goes directly to the application.
Get more development news like this
To create a searchable item, we import CoreSpotlight, then set up attributes and index them. One important attributes is the expiration date. Suppose you want to highlight a sale that will end in two weeks, you can set an expiration date, and it will be removed from indexing automatically.
To note, an Attribute set is responsible for visualization of your item in the core Spotlight, and a Domain identifier is useful when you want work with items in a group; taking clothes as an example if you want to remove a group of items for sale.
It is important to index items asynchronously with a begin batch and end batch. An example of this can be found here: GitHub link.
To open an item into your application from Spotlight, you need to perform three main steps:
- Implement a protocol in your AppDelegate
- Recognize the activity by its
- Get the item from the dictionary.
NSUserActivity is something that you use only for visible content. It allows for capture the state of your app and put it to use later. To create a NSUserActivity, you first should decide if you want to make something public or private. If you make it public, it means that every user should see the screen. It should not contain any private information of the user.
Suppose there is a shoe catalog with Armani shoes. I can make a NSUserActivity with these shoes, and when the user types in the keywords and clicks on the result, they will be directed to the exact screen in the catalog.
In iOS 10, it’s possible to have weak binding. For example, you’re able to index an item to an existing NSUserActivity. You can also keep NSUserActivity up to date the same way as NSSearchableItem - it’s now possible to remove an activity.
How you handle this in the app is the same. There will be a specific type for your activity, and you’ll have a delegate/handler that will redirect to your page. A best practice here is to always connect CSSearchableItem with NSUserActivity if they link into the same information or if they show the same screen in the end.
Web markup is a web related API. If you don’t have a corresponding website, there is no sense to use this API. This will always be public, so there is no way to make it private or local for a user.
To use this API, you will need to perform three steps.
- Add deep links to your website markup.
- Add robots TXT for crawler
- Use markup to provide a user with nice looking information.
You also can engage users more with
addUniversalLink and smart banners. Universal links are links that open an app from search results in Safari as opposed to another web page. To do this, you need to add your domains that you will support in your project, then handle the constant
NSUserActivityTypeBrowsingWeb in your AppDelegate to redirect to the proper page.
This API is smart enough to remember previous user choices. If you clicked to go into the app from an initial result, it will go straight to the app the next time. There are problems with this, however. In our case, we would not want the user to come into the app for everything - payment links for example, as we want this to occur in the web. A solution to this was to make certain exceptions where we did not want the app to open.
The reasons to integrate this feature are obvious. You will have quick access to the application from a lot of entry points, you will get top results in Spotlight, and if the user was searching for something related to your application, it increases the user engagement.
About the content
This talk was delivered live in March 2017 at try! Swift Tokyo. The video was recorded, produced, and transcribed by Realm, and is published here with the permission of the conference organizers.