notifications: add NSLog diagnostics + explicit .active interruption level
Helps diagnose why .list-style entries aren't landing in Notification Center on macOS — logs willPresent firing and the add() result so we can distinguish 'delivery never happened' from 'system filtered the entry'.
This commit is contained in:
@@ -137,11 +137,19 @@ public class NotificationsPlugin: NSObject, NativePlugin, FlutterStreamHandler,
|
||||
if let t = threadId { content.threadIdentifier = t }
|
||||
content.userInfo = data
|
||||
content.sound = .default
|
||||
// .active is the implicit default but spelling it out clarifies that
|
||||
// we want both a banner AND a Notification Center entry. .passive
|
||||
// would suppress the banner; .timeSensitive would pierce focus.
|
||||
if #available(macOS 12.0, *) {
|
||||
content.interruptionLevel = .active
|
||||
}
|
||||
|
||||
let request = UNNotificationRequest(identifier: id, content: content, trigger: nil)
|
||||
UNUserNotificationCenter.current().add(request) { error in
|
||||
if let error = error {
|
||||
NSLog("ux notifications: add failed: \(error)")
|
||||
} else {
|
||||
NSLog("ux notifications: posted id=\(id) thread=\(threadId ?? "-")")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,9 +211,12 @@ public class NotificationsPlugin: NSObject, NativePlugin, FlutterStreamHandler,
|
||||
// it as a banner — entries never reach Notification Center. The
|
||||
// 11+ split is `.banner` + `.list`; we need both so the toast
|
||||
// shows AND persists in the tray.
|
||||
let id = notification.request.identifier
|
||||
if #available(macOS 11.0, *) {
|
||||
NSLog("ux notifications: willPresent id=\(id) → [.banner, .list, .sound]")
|
||||
completionHandler([.banner, .list, .sound])
|
||||
} else {
|
||||
NSLog("ux notifications: willPresent id=\(id) → [.alert, .sound]")
|
||||
completionHandler([.alert, .sound])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user