Post

Replies

Boosts

Views

Activity

Interaction donation fails
I have just gotten started working with intents and donating them after I got help - https://developer.apple.com/forums/thread/673701 figuring out how to make them work. Now, I'm getting an unknown error when trying to donate my INInteraction: swift let interaction = INInteraction(intent: drink.intent, response: nil) interaction.identifier = drink.id.uuidString interaction.donate(completion: { error in if error != nil { if let error = error as NSError? { print("Interaction donation failed: ", error) } } else { print("Successfully donated interaction") } }) The error I'm getting is: Interaction donation failed:  Error Domain=IntentsErrorDomain Code=1901 "(null)" UserInfo={NSUnderlyingError=0x600001a97ed0 {Error Domain=CSIndexErrorDomain Code=-1003 "(null)"}} I've been searching a lot without success. What's going on here?
1
0
962
Feb ’21
Shortcut/Action on Siri Watch Face with independent WatchOS app
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: let intent = INManager.intent(drink: item) INManager.donateShortcuts(withIntent: intent) and my IntentManager looks like this: 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.
1
0
904
Feb ’21