When I try to access the data in my IntentTimelineProvider in the recommendations function using App Groups, it is always empty "no data".
func recommendations() -> [IntentRecommendation<IndicatorIntent>] {
if let sharedUD = UserDefaults(suiteName: "group.measurements") {
let jm = JanitzaMeasurementValue(identifier: "1", display: "2")
let intent = IndicatorIntent()
intent.indicatorWidgetData = jm
let desc = sharedUD.string(forKey: "string") ?? "no data"
return [IntentRecommendation(intent: intent, description: desc)]
}
return []
}
Although I write this in both the watchOS and iOS app using App Groups.
if let sharedUD = UserDefaults(suiteName: "group.measurements") {
sharedUD.set("test", forKey: "string")
}
What is the right way to dynamically implement the widgets for Complications in watchOS? Like for example in Shortcuts App.
**Thanks for support **
The best way to share across iOS / WatchOS would be using NSUbiquitousKeyValueStore to share and sync small, not often changing data with the cloud. App Groups won't work across targets like Watch and iOS because they are different platforms with different App Group file locations. Yes, App Groups can share data but think of them as an on-device thing with available across processes that can access the same App Group location (apps associated with your team ID).
Rico
WWDR | DTS | Software Engineer