fix: widgets use App Group shared UserDefaults instead of Keychain
- Widgets can't access app's Keychain (different sandbox) - App writes data to shared UserDefaults (group.com.daniil.pulsehealth) - Widgets read from shared UserDefaults — no API calls needed - WidgetDataService: updates widget data + reloads timelines - DashboardView: pushes habits/tasks data to widget after load - HealthView: pushes health data to widget after load - App Group capability added to both app and widget entitlements - Widgets update every 15 minutes from cached data Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -200,6 +200,14 @@ struct HealthView: View {
|
||||
async let h = HealthAPIService.shared.getHeatmap(days: 7)
|
||||
readiness = try? await r; latest = try? await l; heatmapData = (try? await h) ?? []
|
||||
isLoading = false
|
||||
|
||||
// Update widget
|
||||
WidgetDataService.updateHealth(
|
||||
steps: latest?.steps?.total ?? 0,
|
||||
sleep: latest?.sleep?.totalSleep ?? 0,
|
||||
heartRate: Int(latest?.restingHeartRate?.value ?? 0),
|
||||
readiness: readiness?.score ?? 0
|
||||
)
|
||||
}
|
||||
|
||||
func syncHealthKit() async {
|
||||
|
||||
Reference in New Issue
Block a user