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:
@@ -199,7 +199,15 @@ public class NotificationsPlugin: NSObject, NativePlugin, FlutterStreamHandler,
|
|||||||
withCompletionHandler completionHandler:
|
withCompletionHandler completionHandler:
|
||||||
@escaping (UNNotificationPresentationOptions) -> Void,
|
@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(
|
public func userNotificationCenter(
|
||||||
|
|||||||
Reference in New Issue
Block a user