I am trying to add a watch widget that I've created for Smart Stack feature of watchOS 10 to also appear in the list of shortcuts shown in the Siri Watch Face.
It seems like Apple now wants us to use RelevantIntentManager
for this purpose, but my widget never shows up in the Siri Watch face.
This is the code that I am using.
func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline<GenericEntry> {
[...]
await updateRelevantIntents()
return timeline
}
func updateRelevantIntents() async {
var relevantIntents = [RelevantIntent]()
let defaults = UserDefaults.init(suiteName: "group.tesla.watch.maadotaa")!
guard let name2VIN = defaults.dictionary(forKey: Constants.VEHICLE_NAME_VIN_DICT) as? [String:String] else {
return
}
let carNames = Array(name2VIN.keys)
for (idx, name) in carNames.enumerated() {
let intent = ConfigurationAppIntent()
intent.order = idx
intent.carName = name
intent.action = nil
let txt = "\(name): info only"
let relIntent = RelevantIntent(intent, widgetKind: "WatchWidget", relevance: RelevantContext.date(from: .now, to: .now + 3600 * 1))
relevantIntents.append(relIntent)
}
do {
try await RelevantIntentManager.shared.updateRelevantIntents(relevantIntents)
} catch (let error) {
print("\(#function): \(error.localizedDescription)")
}
}