2023-07-06 17:18:41 +03:30
|
|
|
import Cocoa
|
|
|
|
|
import FlutterMacOS
|
|
|
|
|
|
2024-08-05 15:17:10 +02:00
|
|
|
import UserNotifications
|
2024-08-20 14:30:21 -04:00
|
|
|
@main
|
2023-07-06 17:18:41 +03:30
|
|
|
class AppDelegate: FlutterAppDelegate {
|
|
|
|
|
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
2023-08-25 13:29:55 +03:30
|
|
|
// https://github.com/leanflutter/window_manager/issues/214
|
|
|
|
|
return false
|
2023-07-06 17:18:41 +03:30
|
|
|
}
|
2024-08-05 15:48:20 +02:00
|
|
|
override func applicationDidFinishLaunching(_ aNotification: Notification) {
|
2024-08-04 22:51:36 +02:00
|
|
|
// Request notification authorization
|
|
|
|
|
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge]) { granted, error in
|
|
|
|
|
if let error = error {
|
|
|
|
|
print("Error requesting notification authorization: \(error)")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-16 18:16:46 +03:30
|
|
|
|
2023-12-28 23:16:56 +03:30
|
|
|
// // window manager restore from dock: https://leanflutter.dev/blog/click-dock-icon-to-restore-after-closing-the-window
|
|
|
|
|
// override func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
|
|
|
|
// if !flag {
|
|
|
|
|
// for window in NSApp.windows {
|
|
|
|
|
// if !window.isVisible {
|
|
|
|
|
// window.setIsVisible(true)
|
|
|
|
|
// }
|
|
|
|
|
// window.makeKeyAndOrderFront(self)
|
|
|
|
|
// NSApp.activate(ignoringOtherApps: true)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return true
|
|
|
|
|
// }
|
2023-07-06 17:18:41 +03:30
|
|
|
}
|