First, you should set the delegate before you send the -deliverNotification:
message. If you don’t, it’s possible that your delegate method won’t be triggered even when it’s supposed to be.
Second, in the documentation for -userNotificationCenter:shouldPresentNotification:
, it states:
userNotificationCenter:shouldPresentNotification:
Sent to the delegate when the user notification center has decided not to present your notification.
i.e. you will only see this method invoked when NSUserNotificationCenter
has already decided not to show your notification. If it has decided that it should show it, it won’t bother asking.