I'm relatively new to making apps, and even newer to independent watch apps. As training, I'm making a watch app that I can use to log my water intake throughout the day. I've created a new intent definition file (see image 1) on which I've checked the marks for all the target memberships (the app, the WatchKit app, and the WatchKit extension). Furthermore, the target membership class is a public intent for the WatchKit extension.
When logging my water I execute the following code:
and my IntentManager looks like this:
When logging a drink the confirmation Returning relevant shortcut. and Relevant shortcuts set. are printed. However, the Siri watch face doesn't update to include a link to my action. I really appreciate your time and help. I've had a hard time trying to find any details about this functionality. Thank you! If you need more details or such, feel free to ask.
When logging my water I execute the following code:
Code Block swift let intent = INManager.intent(drink: item) INManager.donateShortcuts(withIntent: intent)
and my IntentManager looks like this:
Code Block swift import Foundation import Intents class IntentManager { func intent(drink: Drink) -> LogDrinkIntent { let intent = LogDrinkIntent() intent.uuid = drink.id.uuidString intent.name = drink.name intent.emoji = drink.emoji return intent } func donateShortcuts(withIntent intent:INIntent) { var relevantShortcuts: [INRelevantShortcut] = [] if let relevantShortcut = defaultRelevantShortcut(withIntent: intent) { relevantShortcuts.append(relevantShortcut) } INRelevantShortcutStore.default.setRelevantShortcuts(relevantShortcuts) { (error) in if let error = error { print("Failed to set relevant shortcuts: \(error))") } else { print("Relevant shortcuts set.") } } } private func defaultRelevantShortcut(withIntent intent: INIntent) -> INRelevantShortcut? { if let shortcut = INShortcut(intent: intent) { let relevantShortcut = INRelevantShortcut(shortcut: shortcut) relevantShortcut.shortcutRole = .action let template = INDefaultCardTemplate(title: "Log Drink") relevantShortcut.watchTemplate = template print("Returning relevant shortcut.") return relevantShortcut } return nil } }
When logging a drink the confirmation Returning relevant shortcut. and Relevant shortcuts set. are printed. However, the Siri watch face doesn't update to include a link to my action. I really appreciate your time and help. I've had a hard time trying to find any details about this functionality. Thank you! If you need more details or such, feel free to ask.