Add background task for overnight widget data refresh

- Create BackgroundTaskManager that schedules refresh at random time
  between 12:00 AM - 4:00 AM local time
- Fetches tasks from API, writes to DataManager and shared App Group
- Reloads widget timelines after refresh
- Register task in AppDelegate, schedule when app goes to background
- Add BGTaskSchedulerPermittedIdentifiers and fetch/processing modes to Info.plist

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-23 20:36:17 -06:00
parent 4daaa1f7d8
commit 556b187508
5 changed files with 256 additions and 41 deletions

View File

@@ -1,5 +1,6 @@
import UIKit
import UserNotifications
import BackgroundTasks
import ComposeApp
class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {
@@ -14,6 +15,9 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele
// Register notification categories for actionable notifications
NotificationCategories.registerCategories()
// Register background tasks for overnight data refresh
BackgroundTaskManager.shared.registerBackgroundTasks()
// Request notification permission
Task { @MainActor in
await PushNotificationManager.shared.requestNotificationPermission()