notifications: persist macOS toasts in Notification Center

Returning [.alert, .sound] from willPresent shows the banner but never
adds the entry to Notification Center — .alert has been a banner-only
shim since macOS 11. On 11+ we need [.banner, .list] for the entry to
stick after the banner auto-dismisses.
This commit is contained in:
agra
2026-05-27 13:05:49 +03:00
parent f5d32a828f
commit 68b97ce100

View File

@@ -199,7 +199,15 @@ public class NotificationsPlugin: NSObject, NativePlugin, FlutterStreamHandler,
withCompletionHandler completionHandler:
@escaping (UNNotificationPresentationOptions) -> Void,
) {
completionHandler([.alert, .sound])
// `.alert` is deprecated since macOS 11 and the system only honours
// 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.
if #available(macOS 11.0, *) {
completionHandler([.banner, .list, .sound])
} else {
completionHandler([.alert, .sound])
}
}
public func userNotificationCenter(