问题
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