I’ve finally made peace with having to index a notes file as a whole rather than as separate items. However, I’ve run into another issue:
I built a CSImportExtension and tested it on iOS. The indexed file appears in Spotlight search results, but when tapped, the app only receives a URL context, not an activity object containing the search query. As a result, I can open the file, but I can’t scroll to the relevant section because I don’t know what the user searched for.
The app has its own search feature, but the user has to re-enter the query, which is a poor user experience.
If I index the content as a CSSearchableItem, the app receives a CSSearchableItemActionType activity, which includes the query string. However, as you’ve explained, files are meant to be indexed as a whole, not as individual CSSearchableItem objects.
I then thought that adding a "Search in App" button would solve this, so I added CoreSpotlightContinuation to the Info.plist. While this does provide the query string in a CSQueryContinuationActionType activity, the button only appears for items indexed as CSSearchableItem. For content indexed via CSImportExtension, the button appears but it opens the Files app instead of my app.
The question is: How can I index files using CSImportExtension and still receive the query string in a user activity, rather than just a bare URL context?
Topic:
App & System Services
SubTopic:
Core OS
Tags: