按应用通知会始终激活应用窗口

问题描述 投票:0回答:1

我的应用程序安排通知并很好地显示它

NSUserNotificationCenter.default.delegate = self

let notification = NSUserNotification()
notification.deliveryDate = Date(timeIntervalSinceNow: TimeInterval(10))
notification.title = title
notification.actionButtonTitle = "Do something"

notification.soundName = notificationSound != "none" ? notificationSound : nil
notification.otherButtonTitle = "Close"

NSUserNotificationCenter.default.scheduleNotification(notification)

当我按下按钮激活方法时叫好

func userNotificationCenter(_ center: NSUserNotificationCenter, didActivate notification: NSUserNotification) {
    DDLogDebug("Did activate notification")

    switch notification.activationType {
       ...
}

问题是打开的窗口在按下不需要的窗口后被激活。

应用程序是代理(UIElement),其中打开了多个窗口。尝试了非代理应用程序,问题仍然存在-它会激活主窗口

有什么想法吗?

swift macos cocoa notifications
1个回答
0
投票

很遗憾,我没有找到答案。我实现了自己的显示UIPanel的通知机制

© www.soinside.com 2019 - 2024. All rights reserved.