Files
Reflect/Shared/FeelsApp.swift
Trey t 675e44bca9 fix issue with two votes on the same date
fix issue with header not showing correct vote date
split logic for Persistence into different files
create class that deals with voting time, existing votes, and what should be shown based on that
2022-02-17 14:46:11 -06:00

46 lines
1.4 KiB
Swift

//
// FeelsApp.swift
// Shared
//
// Created by Trey Tartt on 1/5/22.
//
import SwiftUI
import BackgroundTasks
import WidgetKit
@main
struct FeelsApp: App {
@Environment(\.scenePhase) private var scenePhase
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
let persistenceController = PersistenceController.shared
init() {
BGTaskScheduler.shared.cancelAllTaskRequests()
BGTaskScheduler.shared.register(forTaskWithIdentifier: BGTask.updateDBMissingID, using: nil) { (task) in
BGTask.runFillInMissingDatesTask(task: task as! BGProcessingTask)
}
UIApplication.shared.applicationIconBadgeNumber = 0
}
var body: some Scene {
WindowGroup {
ContentView()
.environment(\.managedObjectContext, persistenceController.viewContext)
}.onChange(of: scenePhase) { phase in
if phase == .background {
BGTask.scheduleBackgroundProcessing()
WidgetCenter.shared.reloadAllTimelines()
}
if phase == .active {
UIApplication.shared.applicationIconBadgeNumber = 0
print("UserDefaultsStore input day", UserDefaultsStore.getOnboarding().inputDay)
print("UserDefaultsStore input date", UserDefaultsStore.getOnboarding().date)
}
}
}
}