Ranchero-Software / NetNewsWire

RSS reader for macOS and iOS.
https://netnewswire.com/
MIT License
8.29k stars 526 forks source link

iOS: Siri Shortcuts aren't cleaned up #904

Closed vincode-io closed 4 years ago

vincode-io commented 5 years ago

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.

vincode-io commented 5 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.

https://github.com/vincode-io/NSUserActivityDeleteTest

vincode-io commented 4 years ago

I noticed this slide while watching a 2018 WWDC video. It was Introducing Siri Shortcut, I think.

Screen Shot 2019-10-18 at 11 29 20 AM

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.