I'm embarrassed to ask this because I feel like I am just missing something super simple.
In our app we keep a search history of destinations that the user searches for. I wanted to make these available to Spotlight and Siri suggestions. When I add the history items to Spotlight everything behaves as expected. I can see the items in Spotlight, select them and it triggers the search again for that specific history item. When I add the item to the search index I am also creating an NSUserActivity object and setting it to current so that we can also benefit from Handoff. Where my issue is happening is when I try to set the NSUserActivity to eligible for prediction and add a persistent identifier for the Siri suggestions. When I do this and I perform a search then I do still see the spotlight indexed item as well as a suggestion by Siri as expected. However, if I do a second search, even for the same item, when I try to access Spotlight to see my entries then I get a SpringBoard crash.
I was previously doing this without Spotlight and just using NSUserActivity, but realized that wasn't the right approach, since I also need to delete items from the index if the user deletes their history in the app. When I was just using NSUserActivity it did not crash, but the indexing in Spotlight was not what I wanted and would disappear after a time. But I don't know what I have done wrong with setting up the Spotlight index and setting the NSUserActivity that would cause a SpringBoard crash when donating more than one item.
A brief bit about our setup:
* I have created an ActivityHandler class that pulls the necessary info together to donate everything.
* Our backend target will pass the necessary data to the ActivityHandler class based on the user actions of performing a search or tapping on a search history item.
* In the ActivityHandler I am setting up the Spotlight item first and adding it to the index.
* In the completion handler of CSSearchableIndex I am setting up the user activity, setting it to becomeCurrent and then adding it to a property in the class that holds it so that it is not deallocated after the method ends.
I am completely stumped on what I am doing wrong. Any insights from anybody would be greatly appreciated.
I just tried and installed a build on a device with iOS 13 beta 7 and it works as expected. The previous device and simulator version that I was testing on was iOS 12.0 and 12.4.