How to find out style of NSUserNotification during run-time? Or force close an alert?
Posted
by
Dmitri Shuralyov
on Stack Overflow
See other posts from Stack Overflow
or by Dmitri Shuralyov
Published on 2012-09-09T03:35:51Z
Indexed on
2012/09/09
3:37 UTC
Read the original article
Hit count: 162
cocoa
|nsusernotification
According to "OS X Mountain Lion Release Notes" (https://developer.apple.com/library/mac/#releasenotes/Cocoa/Foundation.html),
"The user has ultimate control over what notifications are displayed, and the style (banner, alert, etc). There is no mechanism to override the user preferences."
Even though all I want to do is "downgrade" from alert style to banner style... Fine. But can I at least find out whether a notification is of alert or banner style inside the didActivateNotification method?
The reason I want to do that is to respond differently according to notification.activationType
.
When the alert is a banner (which is what I want), clicking its contents is the only possible action, and this both triggers didActivateNotification method and closes the notification banner.
When the user chooses alert-style notifications, clicking the alert contents also generates didActivateNotification with the same value of notification.activationType
, but it stays on screen instead of going away (it only goes away when the Action button is pressed). I don't want my app to trigger an action repeatedly for the same alert notification, in case the user clicks the content area of an alert notification.
An alternative solution would be to force the alert notification bubble to dismiss when the user clicks its contents. Is this possible?
© Stack Overflow or respective owner