0
votes

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?

3
What are you setting the thumbnailURL to? Have you tried using the thumbnailData property instead?dan
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

3 Answers

0
votes

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

0
votes

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

0
votes

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.