swiftcocoansusernotification

Property additionalActions of NSUserNotification seems not working?


To understand NSUserNotification better, I wrote a little test app playing with this class.

So far so good, except that no matter how hard I tried to feed the additionalActions property with array of NSUserNotificationAction objects, it never showed any difference but only one action button and a close one.

My expectation for this property is that the notification would show a pull-down menu containing the additional buttons I offer as it does in the Mac App Store update notifications.

Am I missing something? Or are you having the same problem, since it is a bug awaiting Apple to tackle?


Solution

  • Can you please try to click and hold down the action button in your notification? Does it show a drop-down menu of additionalActions?


    Update

    As it turns out, you can show the little chevron next to the action button by setting a true value for the private _alwaysShowAlternateActionMenu key on the notification. In Swift 3, it would look like this:

    notification.setValue(true, forKey: "_alwaysShowAlternateActionMenu")
    

    However, as I mentioned this is a private API and I strongly advise against using it if you want to distribute your App through the Mac App Store.