Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: Siri Shortcuts aren't cleaned up #904

Closed
vincode-io opened this issue Aug 28, 2019 · 2 comments
Milestone

Comments

@vincode-io
Copy link
Collaborator

@vincode-io vincode-io commented Aug 28, 2019

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 vincode-io added this to the 5.0 iOS Alpha milestone Aug 28, 2019
@vincode-io

This comment has been minimized.

Copy link
Collaborator Author

@vincode-io vincode-io commented Sep 14, 2019

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 added a commit that referenced this issue Oct 18, 2019
@vincode-io

This comment has been minimized.

Copy link
Collaborator Author

@vincode-io vincode-io commented Oct 18, 2019

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.
@vincode-io vincode-io closed this Oct 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.