made bgview equatable so it doesn't get redrawn each time a sheet is shown add more string to localization fill in missing data on launch ... incase they have bgfetch turned off
45 lines
1.3 KiB
Swift
45 lines
1.3 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() {
|
|
persistenceController.fillInMissingDates()
|
|
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.container.viewContext)
|
|
}.onChange(of: scenePhase) { phase in
|
|
if phase == .background {
|
|
BGTask.scheduleBackgroundProcessing()
|
|
print("background")
|
|
WidgetCenter.shared.reloadAllTimelines()
|
|
}
|
|
|
|
if phase == .active {
|
|
UIApplication.shared.applicationIconBadgeNumber = 0
|
|
}
|
|
}
|
|
}
|
|
}
|