05/15 Update: show issue's images, push notifications
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
import BackgroundTasks
|
||||
import UserNotifications
|
||||
|
||||
@main
|
||||
struct JanitorialQCApp: App {
|
||||
@@ -14,6 +15,7 @@ struct JanitorialQCApp: App {
|
||||
|
||||
init() {
|
||||
registerBackgroundTasks()
|
||||
requestNotificationPermission()
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
@@ -44,6 +46,19 @@ 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(
|
||||
options: [.alert, .sound, .badge]
|
||||
) { granted, error in
|
||||
if let error { print("[JQC] Notification permission error: \(error)") }
|
||||
}
|
||||
}
|
||||
|
||||
private func registerBackgroundTasks() {
|
||||
BGTaskScheduler.shared.register(
|
||||
forTaskWithIdentifier: "com.jqc.sync",
|
||||
|
||||
Reference in New Issue
Block a user