I have created a searchable NSUserActivity in iOS 9 as follows.
userActivity = [[NSUserActivity alloc] initWithActivityType:@"com.example.app.conversation"];
userActivity.title = @"Conversation with Fred Thompson";
**userActivity.keywords = [NSSet setWithObjects:@"Holiday" @"Summer", nil];**
userActivity.userInfo = @{@"keyOne":@"valueOne", @"keyTwo":@"valueTwo"};
userActivity.eligibleForSearch = YES;
userActivity.eligibleForPublicIndexing = NO;
userActivity.eligibleForHandoff = NO;
userActivity.contentAttributeSet = attributeSet;
[userActivity becomeCurrent];
and I have registered the following activity type in my info.plist:
com.example.app.conversation
In Spotlight, I can search for any words of the TITLE and find my UserActivity; however, none of the KEYWORDS work for finding my UserActivity.
So, search for "Fred Thompson" will return the activity because those words are in the title; however search for "Holiday Summer" will return no results. (Note: that keywords are working for me with CSSearchableItems). Yes, I've also tried using obscure words just to ensure my results are not getting drowned out by other more popular results.
However, in no case, can I find my NSUSerActivity by the provided keywords. What am I doing wrong?
contentAttributeSet
property of the user activity with aCSSearchableItemAttributeSet
instance (which has anotherkeywords
property. Note that you need to importCoreSpotlight
in order to see thecontentAttributeSet
property onNSUserActivity
. – hagi