0

I use NSUSerActivity and CoreSpotlight for indexing. I set the thumbnailURL in the contentAttributesSet property as usual. Images are downloaded from a server and the activity object is created before the image get's downloaded. So I set a "placeholder" image and when I have the chance I update contentAttributesSet.thumbnailURL to the correct one. But when I try to search for the same item in Spotlight the image stays the same.

Is there any special condition that I have to be aware of when updating such info?

Matthew Herbst
  • 29,477
  • 23
  • 85
  • 128
i-konov
  • 842
  • 1
  • 7
  • 19
  • What are you setting the `thumbnailURL` to? Have you tried using the `thumbnailData` property instead? – dan Jan 20 '16 at 18:13
  • I am setting it to a file URL located in the Caches directory. It is way easier than using the data property because of the needed resizing of the images. – i-konov Jan 20 '16 at 20:29

3 Answers3

0

Thumbnail URL is only for local urls. not remote ones. You have to use thumbnailData.

V V
  • 774
  • 1
  • 9
  • 29
  • 1
    It is used for a local file. It turns out there is a bug with that. There are people complaining about the same issue on the Apple forums as well. No matter how you set it, once a thumbnail is set there is no replacing it. – i-konov Jan 25 '16 at 18:38
  • I didn't try `thumbnailURL` but the problem of `thumbnailData` - `CoreSpotlight` caches it and it seems you can't refresh this cache via code. – Vyachaslav Gerchicov Aug 05 '16 at 14:22
0

I think that was a bug in iOS 9.0 - 9.2. It seems to be working well on iOS 9.3+

i-konov
  • 842
  • 1
  • 7
  • 19
0

As best I can determine, this is an issue with caching a thumbnail for a specific NSUserActivity. The CoreSpotlight framework seems to associate the icon data with the activityType, so even creating a new NSUserActivity object won't allow you to update the icon image. The best you can do is to keep track of all the persistent identifiers internally, delete the old one, and create a brand new NSUserActivity which the user will have to treat as a new shortcut as well.

It's definitely a dumb issue, and I'd have hoped that in the 3.5 years since iOS 9 came out, Apple would have introduced a way to update an NSUserActivity's thumbnail image.