MacOS – AppleScript to read all notifications in the Notification Center OSX 10.10 Yosemite

applescriptmacosnotifications

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?

Best Answer

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.