简体   繁体   中英

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?

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.

It is probably a bug. Setting up additionalActions will create the list, but not the little arrow icon. Holding down on actionButton will show the menu with the number of actions you set.

Besides setting additionalActions will cause several other problems. I will save this for another question.

Refer to another question. show NSUserNotification additionalActions on click

PS I am using El Capitan APIs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM