Files
iceglass/IceGlass/AppDelegate.swift
T
rzen 8f8f8b2755 Initial commit: IceGlass NHL game tracker
macOS menu bar app providing NHL game situational awareness with
league-wide scoreboard, dynamic polling, notifications with team
logos, and configurable display options.
2026-04-13 21:44:08 -04:00

46 lines
1.4 KiB
Swift

//
// AppDelegate.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import UserNotifications
import AppKit
class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {
private let logger = IceGlassLogger(
subsystem: Bundle.main.bundleIdentifier ?? "dev.rzen.indie.IceGlass",
category: "AppDelegate"
)
private var mainService = MainService.shared
func applicationDidFinishLaunching(_ notification: Notification) {
logger.info("applicationDidFinishLaunching")
UNUserNotificationCenter.current().delegate = self
// Set app icon explicitly (LSUIElement apps may not pick it up automatically)
if let icon = NSImage(named: "AppIcon") {
NSApp.applicationIconImage = icon
}
}
func applicationWillTerminate(_ notification: Notification) {
// nothing to deinit
}
// Notification click handler opens URLs
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
if let urlString = response.notification.request.content.userInfo["url"] as? String,
let url = URL(string: urlString) {
NSWorkspace.shared.open(url)
}
completionHandler()
}
}