Can an app use both alerts and banners in Notification Center?

五迷三道 提交于 2019-12-10 12:45:38

问题


I am creating a Mac OS X application to use Notification Center. Some notifications should remain on the screen until the user interacts with them, and others should disappear shortly after displaying.

The NSUserNotificationAlertStyle key and changing System Preferences allow changing between banners and alerts. However, both approaches change all the notifications sent from my application.

Can I send some notifications as alerts and others as banners? If so, how?


回答1:


NSUSerNotificationAlertStyle is the only way the developer can set the default notification style for the application, and it sets the style for all notifications from that app.

If you think it's really important for you to have 2 different kinds of notifications you can work around the problem by having a hidden helper application with a different NSUserNotificationAlertStyle than the main app.

Remember though you set the default notification style, but the user can change it whenever he wants in the notification center prefs, making your helper app useless.




回答2:


No. The different notification types exist so that the user may select what he/she prefers, not so that the developer can.

If you feel your app should have this ability, you should file an enhancement request at http://bugreporter.apple.com and let Apple know.



来源:https://stackoverflow.com/questions/12320051/can-an-app-use-both-alerts-and-banners-in-notification-center

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!