I added Web Markup to my website so items will appear in Spotlight Search results when users search in iOS 9. Users can browse the same items in the app, therefore I want to create NSUserActivity objects that link to the web content as users browse the items.
Now, NSUserActivity has a contentAttributeSet property which I will use to to attach a thumbnail photo to the activity. CSSearchableItemAttributeSet has some properties that NSUserActivity also has, so I am not sure which one I should implement or if I should specify the same data for both. Do I set the title for the NSUserActivity as well as the title on the CSSearchableItemAttributeSet, or only one or the other? Same with keywords which is a property on both as well.
NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@“com.domain.appname-something"];
activity.title = @“My Title";
activity.keywords = [NSSet setWithArray:@[@“one", @“two", @“three"]];
activity.userInfo = @{@“id": @“12345"};
activity.requiredUserInfoKeys = [NSSet setWithArray:@[@“id"]];
activity.eligibleForSearch = YES;
activity.eligibleForPublicIndexing = YES;
activity.webpageURL = [NSURL URLWithString:@"https://someurl.com"];
//QUESTION: Do I need to duplicate title and keywords here:
CSSearchableItemAttributeSet *contentAttributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString *)kUTTypeImage];
contentAttributeSet.title = activity.title;
contentAttributeSet.displayName = activity.title;
contentAttributeSet.keywords = [activity.keywords allObjects];
contentAttributeSet.contentDescription = @“My Description Here";
contentAttributeSet.thumbnailData = [self generateImage];
activity.contentAttributeSet = contentAttributeSet;
After talking with DTS on this topic, this is their conclusion: