45.4 Donating Shortcuts
An app typically donates a shortcut when a common action is performed by the user. This donation does not automatically turn the activity into a shortcut, but includes it as a suggested shortcut within the iOS Shortcuts app. A donation is made by calling the donate() method of an INInteraction instance which has been initialized with a shortcut intent object. For example:
let intent = OrderFoodIntent()
intent.menuItem = "Cheeseburger"
intent.quantity = 1
intent.suggestedInvocationPhrase = "Order Lunch"
let interaction = INInteraction(intent: intent, response: nil)
interaction.donate { (error) in
if error != nil {
// Handle donation failure
}
}