Reputation: 321
I have a little app which is using NSNotificationCenter
to schedule notifications. I have no problems to access them during runtime and all works fine.
The problem starts when I close the app and restart it. I seem not to have any access to the notifications I scheduled during the first run.
Answers here suggest that there is a .db file in ~/Library/Application Support/NotificationCenter/ but this folder is not there in OS X 10.10 (not hidden, not in any of the other Application Support folders either) but I can see it on my 10.9 partition.
Has anybody an idea where this file is located now or if this functionality has been changed completely and the scheduled notifications are stored elsewhere?
Upvotes: 7
Views: 4573
Reputation: 571
If you just want the path then, in macOS 15.3.1 / Sequoia, the path is : /Users/JohnDoe/Library/Group Containers/group.com.apple.usernoted/db2/db
Bonus points for something that actually uses this (but doesn't yet work for Sequoia): https://github.com/jrmann100/notifwd/
Updated: 2025-02-26__16-37-18 for macOS 15 / Sequoia: (The original version below did not handle whitespaces and truncated the path. This slight modification correctly handles whitespace, but requires that perl be present on the path):
lsof -p $(ps aux | grep -m1 usernoted | awk '{ print $2 }') | grep 'db2/db$' | perl -lpe 's/.*(\/Users.*)/$1/g'
eg output:
/Users/JohnDoe/Library/Group Containers/group.com.apple.usernoted/db2/db
As in 10.14.6 - Mojavae, it could be found using this command:
lsof -p $(ps aux | grep -m1 usernoted | awk '{ print $2 }')| awk '{ print $NF }' | grep 'db2/db$' | xargs dirname
Upvotes: 5
Reputation: 46
As of macOS 15 Sequoia, the database has now moved once again to ~/Library/Group Containers/group.com.apple.usernoted/db2/db
. This is protected from access by other apps by default (which is apparently the purpose of the move) - in order to read it from the Terminal, you will need to grant Terminal "Full Disk Access" in Privacy & Security settings, or you'll get a permission-denied error trying to get into that directory.
(You may still see the -shm and -wal files in the /private/var/folders path left over from older OS versions, but there is no actual database there, so don't let it confuse you.)
pokio:~ geofft$ sqlite3 -readonly ~/Library/Group\ Containers/group.com.apple.usernoted/db2/db
SQLite version 3.43.2 2023-10-10 13:08:14
Enter ".help" for usage hints.
sqlite> .schema record
CREATE TABLE record (rec_id INTEGER PRIMARY KEY, app_id INTEGER, uuid BLOB, data BLOB, request_date REAL, request_last_date REAL, delivered_date REAL, presented Bool, style INTEGER, snooze_fire_date REAL);
Upvotes: 1
Reputation: 255
Also can be found using this command:
/usr/bin/getconf DARWIN_USER_DIR
Upvotes: 3
Reputation: 321
Thanks to some outside help I found out that the .db file location can be seen by doing the following:
usernoted
The files listed there also contain the .db files I was searching for and it is in a /com.apple.notificationcenter/db subfolder under /private/var/folders (sorry for not posting the complete path but there are some pices which seem to be unique to each machine or user).
Upvotes: 12