Is there any non-private way of knowing how many notifications there are in the Notification Center (NSUserNotificationCenter
) in Mountain Lion? Not just notifications from my app, but from all apps.
So, to sum things up, what I want to do is to retrieve the number of notifications displayed here:
I've tried to search around, but I can't find information about this. Any ideas?
Thanks in advance!
Asked
Active
Viewed 640 times
3

Pedro Vieira
- 3,330
- 3
- 41
- 76
-
2Are you considering using private APIs? An off the cuff response to this would be that it is not possible due to app Sandboxing. – Chris Wagner May 28 '13 at 16:44
-
What a shame :/ I was really looking for a public way of doing it, but if it's not possible, it would be awesome to know it, even using private APIs. – Pedro Vieira May 29 '13 at 22:30
-
Running a class-dump on Foundation, reveals nothing of any real interest. The only things of potential interest are `_presentedAlerts` and `_displayedNotifications` on NSUserNotificationCenter. However, both of these seem to return only what the app has created and issued, not what other apps have created. Short of location the Notification Center database and manually reading that, I'm not sure this is possible, public or private API. – Tom Hancocks May 30 '13 at 11:35
1 Answers
7
There is no public API to access notifications from other apps. The best way to access this information is to read the sqlite database located in ~/Library/Application Support/NotificationCenter/<UUID>.db
. Note that this will only work if your app is not sandboxed.

0xced
- 25,219
- 10
- 103
- 255
-
This doesn't seem to be working anymore, I don't have that file. Was it moved someplace else? – Romain Pouclet Oct 26 '15 at 18:24