CoreSpotlight Thumbnail Image not showing up on Spotlight search
Asked Answered
I

1

8

I am trying to make my in app content searchable with help of Core Spotlight. Everything works great, title and description comes but without thumbnail.

here is what I am trying:

CSSearchableItemAttributeSet *attributeSet = [[CSSearchableItemAttributeSet alloc]initWithItemContentType:(NSString *)kUTTypeImage];

attributeSet.title = @"My First Spotlight Search";
attributeSet.contentDescription = @"This is my first spotlight Search";

attributeSet.keywords = [NSArray arrayWithObjects:@"Hello", @"Welcome",@"Spotlight", nil];

UIImage *image = [UIImage imageNamed:@"searchIcon.png"];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
attributeSet.thumbnailData = imageData;

CSSearchableItem *item = [[CSSearchableItem alloc]initWithUniqueIdentifier:@"com.deeplink" domainIdentifier:@"spotlight.sample" attributeSet:attributeSet];

[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler: ^(NSError * __nullable error) {
    if (!error)
        NSLog(@"Search item indexed");
}];
Illusionary answered 15/6, 2015 at 1:24 Comment(2)
I am using same code , everyting woring fine but thumbnail image is not working , any luck @Illusionary ? ThanksLantz
@SarojKumarojha not yet.Illusionary
R
8

The iOS 9 beta 1 release notes state that thumbnails aren't yet working for search results. See: https://developer.apple.com/library/prerelease/ios/releasenotes/General/RN-iOSSDK-9.0/index.html

Rinehart answered 18/6, 2015 at 1:13 Comment(3)
I just confirmed that thumbnails do work as expected in iOS 9 beta 2.Rinehart
they have just disagreed in beta5Inchon
9.3.3 - thumbnails work but are cached and it seems impossible to change them for the same itemLekishalela

© 2022 - 2024 — McMap. All rights reserved.