Add premium backups with retention and iCloud support
This commit is contained in:
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user