You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
34 lines
1.0 KiB
import Cocoa
|
|
import FlutterMacOS
|
|
import UserNotifications
|
|
|
|
@main
|
|
class AppDelegate: FlutterAppDelegate, UNUserNotificationCenterDelegate {
|
|
override func applicationDidFinishLaunching(_ notification: Notification) {
|
|
if #available(macOS 10.14, *) {
|
|
UNUserNotificationCenter.current().delegate = self
|
|
}
|
|
|
|
super.applicationDidFinishLaunching(notification)
|
|
}
|
|
|
|
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
|
return true
|
|
}
|
|
|
|
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
|
|
return true
|
|
}
|
|
|
|
// MARK: - UNUserNotificationCenterDelegate
|
|
|
|
func userNotificationCenter(_ center: UNUserNotificationCenter,
|
|
willPresent notification: UNNotification,
|
|
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
|
if #available(macOS 11.0, *) {
|
|
completionHandler([.banner, .sound])
|
|
} else {
|
|
completionHandler([.alert, .sound])
|
|
}
|
|
}
|
|
}
|
|
|