05/15 Update: inspector issue view

This commit is contained in:
Nguyen Ngo
2026-05-15 16:02:24 -04:00
parent 7320e88dec
commit 1b90c23b3e
3 changed files with 79 additions and 22 deletions
+22 -3
View File
@@ -16,6 +16,9 @@ struct JanitorialQCApp: App {
init() {
registerBackgroundTasks()
requestNotificationPermission()
// Set delegate so notifications display as banners when the app is in
// the foreground. Without this iOS silently drops them.
UNUserNotificationCenter.current().delegate = NotificationDelegate.shared
}
var body: some Scene {
@@ -47,9 +50,6 @@ struct JanitorialQCApp: App {
}
// Local notification permission
// Request permission for local notifications (used by the polling poller
// to alert inspectors of new assignments and follow-up requests).
// Called at init iOS caches the grant; subsequent calls are no-ops.
private func requestNotificationPermission() {
UNUserNotificationCenter.current().requestAuthorization(
@@ -87,6 +87,25 @@ struct JanitorialQCApp: App {
}
}
// Notification delegate
// Allows local notifications to appear as banners while the app is in the
// foreground. Without this delegate iOS discards them silently.
final class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate {
static let shared = NotificationDelegate()
private override init() {}
func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler:
@escaping (UNNotificationPresentationOptions) -> Void
) {
// Show banner + play sound even when the app is active in foreground.
completionHandler([.banner, .sound])
}
}
func scheduleBackgroundSync() {
let request = BGProcessingTaskRequest(identifier: "com.jqc.sync")
request.requiresNetworkConnectivity = true