It seems like the following AppleScript is no longer working in the latest version of the OS X 10.10 (Yosemite):

on run
    tell application "System Events"
        tell process "Notification Center"
            set theseWindows to every window
            display notification (count of theseWindows)
        end tell
    end tell
end run

This were supposed to get all notifications listed in the Notification Center. However, the count attribute always returns 0.

Does anyone know how to retrieve all notifications in the Notification Center different than the script above?

  • That will actually get the Notifications that pop up on your screen – markhunte Nov 10 '14 at 22:40
  • That should be fine. But still that code doesn't work as expected. Can't list all notifications. Seems like the OS X won't allow you to get that listing. – Fabio Moggi Nov 10 '14 at 22:52
  • What do you mean Can't list all notifications.?? It does work. The code is structured to list any open alerts but not the one it throws up on that run. – markhunte Nov 10 '14 at 23:31
  • 1
    In fact, I would like to be able to get a list of SMS from the Messages.app. As far as I am concerned, I don't have access to the SMS database programatically due to Apple security policy. As a workaround, I am doing SMS forwarding by reading the notification center as soon as the message arrives. However, even that approach is just too weak as I am using an applescript to simulate the user experience of reading the SMS. I wish I could have access to the data directly – Fabio Moggi Nov 11 '14 at 5:36

I have not found a way for AppleScript to do this, but shell scripting has been effective for some people to get at the full database or log of past notifications.

The format is an sqlite database, and it can be found inside this folder:

~/Library/Application Support/NotificationCenter

Assuming AppleScript is more important, you can call arbitrary shell scripts if needed from one, but other languages might be easier for database interactions / reporting.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .