v2.0.9 — limit notifications at 80%/95% and on reset

This commit is contained in:
superdooper86
2026-05-07 15:40:13 +02:00
parent 2b48114996
commit b95102cb1b
6 changed files with 72 additions and 7 deletions
+12 -1
View File
@@ -1,6 +1,7 @@
import SwiftUI
import WebKit
import Combine
import UserNotifications
@main
struct ClaudeCheckerApp: App {
@@ -11,7 +12,7 @@ struct ClaudeCheckerApp: App {
}
@MainActor
class AppDelegate: NSObject, NSApplicationDelegate {
class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {
var statusItem: NSStatusItem?
var popover: NSPopover?
var usageViewModel = UsageViewModel()
@@ -23,6 +24,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
NSApp.setActivationPolicy(.accessory)
let center = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.alert, .sound]) { _, _ in }
// Hidden WKWebView to prime the shared cookie store
let config = WKWebViewConfiguration()
config.websiteDataStore = WKWebsiteDataStore.default()
@@ -205,4 +210,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationWillTerminate(_ notification: Notification) {
refreshTimer?.invalidate()
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler handler: @escaping (UNNotificationPresentationOptions) -> Void) {
handler([.banner, .sound])
}
}