Scott
Scott

Reputation: 59

How to see what Siri Shortcuts a user has created

I'm creating a Siri Shortcut and have inserted the "Add to Siri" button that one of the WWDC 2018 videos explains and demos. My question is if I can tell when a user has created this specific shortcut which would leave the button useless or even a bug allowing the user to create multiple shortcuts for the same activity/intent.

Is there a way to access the list of shortcuts that the user has created from my app?

Upvotes: 2

Views: 1535

Answers (2)

Mahdi Moqadasi
Mahdi Moqadasi

Reputation: 2479

Thanks to @ThomasJoulin, I wrote this:

func getOldConnectShortcut(for activity: NSUserActivity, _ completion: @escaping ((INVoiceShortcut?) -> Void)) {
    INVoiceShortcutCenter.shared.getAllVoiceShortcuts { shortcuts, err in
        guard err == nil, let shortcuts = shortcuts, !shortcuts.isEmpty
        else { completion(nil); return }
        for s in shortcuts{
            if s.shortcut.userActivity?.activityType == activity.activityType { completion(s); return }
        }
        completion(nil)
    }
}

Be aware that response comes in background Thread.

Upvotes: 0

Thomas Joulin
Thomas Joulin

Reputation: 6650

You can use INVoiceShortcutCenter getAllVoiceShortcuts

Upvotes: 5

Related Questions