Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show NSUserNotification additionalActions on click

additionalActions

In the image above you can see two notifications on OS X. The first one is from my app and the second is from Apple's Reminders.app. In the image you can see the otherButtonTitle 'Complete' and the actionButtonTitle 'Later'.

The second notification, i.e. the one from Reminders.app behaves quite differently. It gets this little arrow pointing downwards on mouse over indicating that there are more actions when clicked. And indeed, you just need to click once on 'Later' and it will give you a couple more options to choose from.

However, I can't get the same behavior to work for my notification. I don't get the little arrow on mouse over and I don't get more options displayed from a single click on 'Later' (notification just gets dismissed). More options only get displayed when holding down the mouse button on 'Later' which is not obvious.

Am I missing something obvious here? How can I get my notification to have exactly the same as the ones from the Reminders.app?

like image 908
iMaddin Avatar asked Nov 10 '15 13:11

iMaddin


1 Answers

While trying to find a solution for the same problem I found this nice explanation for the NSUserNotificationPrivate class that explains how the Reminders app does it.

https://github.com/indragiek/NSUserNotificationPrivate

If the notification type is set to "Alert", the alternateActionButtonTitles property lets you set an array of additional menu item titles to be shown in an action menu that can be accessed by hovering on the Action button and clicking on the arrow.

Once a notification is handled, the index of the action can be retrieved using the _alternateActionIndex property.

So they are using a private API. As the site's disclaimer say using any of this will result in your app being rejected from the MAS and potentially breaking if the APIs change.

like image 65
Miguel Garcia Avatar answered Oct 19 '22 21:10

Miguel Garcia