Add premium backups with retention and iCloud support

This commit is contained in:
alexandrev-tibco
2026-02-01 11:23:41 +01:00
parent f97f8026bc
commit b5ba6c47a8
4 changed files with 418 additions and 1 deletions
@@ -34,6 +34,16 @@ struct PortfolioJournalApp: App {
.onChange(of: scenePhase) { _, newPhase in
if newPhase == .active {
coreDataStack.refreshWidgetData()
} else if newPhase == .background {
guard iapService.isPremium else { return }
guard UserDefaults.standard.bool(forKey: "backupsEnabled") else { return }
let retention = UserDefaults.standard.integer(forKey: "backupRetentionCount")
let keepCount = [5, 10, 20].contains(retention) ? retention : 10
let includeICloud = UserDefaults.standard.bool(forKey: "cloudSyncEnabled")
_ = BackupService.shared.createBackup(
retentionCount: keepCount,
includeICloud: includeICloud
)
}
}
}