mirror of
https://github.com/NinjaCheetah/RIT-Dining.git
synced 2026-03-03 12:45:28 -05:00
This increased padding is roughly the same as the padding around native iOS components like lists, which makes it look a lot more uniform. The increased padding also makes everything feel a little less cramped.
28 lines
1.0 KiB
Swift
28 lines
1.0 KiB
Swift
//
|
|
// BackgroundRefresh.swift
|
|
// TigerDine
|
|
//
|
|
// Created by Campbell on 1/9/26.
|
|
//
|
|
|
|
import SwiftUI
|
|
import BackgroundTasks
|
|
|
|
/// This is the global function used to tell iOS that we want to schedule a new instance of the background refresh task. It's used both in the main app to automatically reschedule a task when one completes, and also within the dining model to schedule a task when a refresh finishes.
|
|
func scheduleNextRefresh() {
|
|
let request = BGAppRefreshTaskRequest(
|
|
identifier: "dev.ninjacheetah.RIT-Dining.refresh"
|
|
)
|
|
|
|
// Refresh NO SOONER than 6 hours from now. That's not super important since the task will exit pretty much immediately
|
|
// if the cache is still fresh, but we really don't need to try more frequently than this so don't bother.
|
|
request.earliestBeginDate = Date(timeIntervalSinceNow: 6 * 60 * 60)
|
|
|
|
do {
|
|
try BGTaskScheduler.shared.submit(request)
|
|
print("background refresh scheduled successfully")
|
|
} catch {
|
|
print("failed to schedule background refresh: ", error)
|
|
}
|
|
}
|