7

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?

4
  • That will actually get the Notifications that pop up on your screen
    – markhunte
    Nov 10, 2014 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. Nov 10, 2014 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, 2014 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 Nov 11, 2014 at 5:36

1 Answer 1

-1

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.

1
  • The path does not exist on Big Sur...
    – Grynn
    Jul 10, 2021 at 12:41

You must log in to answer this question.

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