Closed vincode-io closed 4 years ago
Here is a test iOS application that demonstrates the problem. If no one can point out that I've done something wrong, I'm going to submit a Feedback for it as a bug in iOS.
I noticed this slide while watching a 2018 WWDC video. It was Introducing Siri Shortcut, I think.
You need to delete using the relatedUniqueIdentifier
that you set on the attributeSet
of the NSUserActivity
. The problem is that if you set the relatedUniqueIdentifier
, the shortcut won't index at all. No error is thrown, you just won't get any CoreSpotlight indexing. The solution is to put a dummy entry into CoreSpotlight before donating your shortcut.
Steps to successfully delete a donated shortcut are:
1) Create a CoreSpotlight
entry with only the uniqueIdentifier
in it
2) Create a NSUSerActivity that has relatedUniqueIdentifier
set to equal uniqueIdentifier
3) Donate the NSUserActivity
by calling becomeCurrent
4) Delete everything using CoreSpotlight
only. The NSUserActivity delete API is worthless.
The code to delete the NSUserActivities that have been donated to the system is in place and being executed in ActivityManager. It was implemented following this documentation: https://developer.apple.com/documentation/sirikit/deleting_donated_shortcuts
The code doesn't work though. I need to get some distance from it to figure it out or someone adventurous could take a look at it and give me a second set of eyes on it.