Continue a CoreSpotlight index in the app

Hi,


I am trying to continue a user activity based on a spotlight index. So I get a continuation callback to `-application:continueUserActivity:restorationHandler:`. I check for the activity's `activityType`. In cases where this type is of my custom type, I can continue as I have all the data that I need. However, in some cases (I don't know why) the type is `com.apple.corespotlightitem`, even though the indexed item was associated with an `NSUserActivity`. I don't exactly know why this happens, but I guess I have to deal with both cases. In the latter, however, I only have the `CSSearchableItemActivityIdentifier` key in the user info dictionary, which is to little to build up the UI for the user to continue the task. I need to prepopulate the search mask with informations that are in the `NSUserActivity`'s `userInfo` dictionary and in the `CSSearchableItemAttributeSet`. It seems like I am not able to access either of them.


How do I get the attribute set when I only have the activity identifier? Or if anybody could explain what I would have to do to ensure that I get back the full `NSUserActivity`, that would work as well.


Best regards,

Michael

Replies

Were you able to find a solution or at least an answer to this? Apple's official guide on App Search shows a snippet comparing the activityType with a custom one, but I too keep getting "com.apple.corespotlightitem" despite initializing my activities with my own type.

Did you add the NSUserActivityTypes array of strings to the Info.plist file?


See here... scroll down to "Activity Types" section for an example.

http://www.raywenderlich.com/84174/ios-8-handoff-tutorial

I know it's several months since you asked, but I just discovered this today.


"com.apple.corespotlightitem" = CSSearchableItemActionType - which is found in CSSeachableItem.h


The activity has a "userInfo" property, a Dictionary. In my case, it has a single key - CSSearchableItemActivityIdentifier, which is the uniqueIdentifier of the CSSearchableItem that I created when I indexed it, originally.