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.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user