diff --git a/ios/Plugin/DailyNotificationBackgroundTasks.swift b/ios/Plugin/DailyNotificationBackgroundTasks.swift index 191699e..a7d89fd 100644 --- a/ios/Plugin/DailyNotificationBackgroundTasks.swift +++ b/ios/Plugin/DailyNotificationBackgroundTasks.swift @@ -177,8 +177,32 @@ extension DailyNotificationPlugin { } private func recordHistory(kind: String, outcome: String) async throws { - // Phase 1: History recording is not yet implemented - // TODO: Phase 2 - Implement history with CoreData - print("DNP-HISTORY: \(kind) - \(outcome) (Phase 2 - not implemented)") + guard let context = PersistenceController.shared.viewContext else { + print("DNP-HISTORY: Cannot record history - CoreData not available") + return + } + + let historyId = UUID().uuidString + let history = History.create( + in: context, + id: historyId, + refId: nil, + kind: kind, + occurredAt: Date(), + durationMs: 0, + outcome: outcome, + diagJson: nil + ) + + do { + if context.hasChanges { + try context.save() + print("DNP-HISTORY: Recorded \(kind) - \(outcome)") + } + } catch { + print("DNP-HISTORY: Failed to save history: \(error.localizedDescription)") + context.rollback() + throw error + } } } diff --git a/ios/Plugin/DailyNotificationPlugin.swift b/ios/Plugin/DailyNotificationPlugin.swift index c5cbfd2..2673b20 100644 --- a/ios/Plugin/DailyNotificationPlugin.swift +++ b/ios/Plugin/DailyNotificationPlugin.swift @@ -1211,11 +1211,11 @@ public class DailyNotificationPlugin: CAPPlugin { } // Delegate to scheduler to schedule next notification (glue logic - will be moved to service) - // Note: DailyNotificationFetcher integration deferred to Phase 2 + // Note: fetcher parameter is unused - scheduler uses fetchScheduler instead (already implemented) let scheduled = await scheduler.scheduleNextNotification( content, storage: storage, - fetcher: nil // TODO: Phase 2 - Add fetcher instance + fetcher: nil // Unused - fetchScheduler handles prefetch scheduling ) // Rollover processing is non-fatal - recovery will handle on next launch if needed diff --git a/ios/Plugin/DailyNotificationReactivationManager.swift b/ios/Plugin/DailyNotificationReactivationManager.swift index 41739d4..e55a4e6 100644 --- a/ios/Plugin/DailyNotificationReactivationManager.swift +++ b/ios/Plugin/DailyNotificationReactivationManager.swift @@ -1061,10 +1061,11 @@ class DailyNotificationReactivationManager { } // Trigger rollover + // Note: fetcher parameter is unused - scheduler uses fetchScheduler instead (already implemented) let scheduled = await scheduler.scheduleNextNotification( content, storage: storage, - fetcher: nil // TODO: Phase 2 - Add fetcher + fetcher: nil // Unused - fetchScheduler handles prefetch scheduling ) if scheduled {