Mac中NotificationCenter残留应用删除

在mac系统的“设置”-“通知”中有很多应用标签,这些标签中有些是我们所需要的,有些是某某某流氓软件,强行装上的(流氓软件卸载后,该应用标签一直存在)。那么这个应用标签该如何清理呢?

上网找了好多方法,其中以删除~/Library/Application Support/NotificationCenter/<id>然后重启,这种方法最火。不知道这种方法实在osx(or macos)的哪个版本上的,本人mbp是osx 10.11.6,在我的mbp上没有NotificationCenter这个目录。对于没有这个目录的可以查看一下getconf DARWIN_USER_DIR这个目录。该目录下有个com.apple.notificationcenter目录,这个目录才是你要找到目录。

mac上NotificationCenter中的应用标签是存储在SQLite3数据库中的。可使用sqlite3 \getconf DARWIN_USER_DIR`com.apple.notificationcenter/db/db`打开sqlite数据库

1
2
3
4
$ sqlite3 `getconf DARWIN_USER_DIR`com.apple.notificationcenter/db/db                                                                                     1 ↵
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
sqlite>

然后可用.tables查看库中的表

1
2
3
4
5
6
7
sqlite> .tables
app_info notifications
app_loc presented_alerts
app_push presented_notifications
app_source scheduled_notifications
dbinfo today_summary_notifications
notification_source tomorrow_summary_notifications

由于sqlite mode默认是list模式,需要将其改为line模式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
sqlite> .show
echo: off
eqp: off
explain: off
headers: off
mode: list
nullvalue: ""
output: stdout
colseparator: "|"
rowseparator: "\n"
stats: off
width:
sqlite> .mode line
sqlite> .show
echo: off
eqp: off
explain: off
headers: off
mode: line
nullvalue: ""
output: stdout
colseparator: "|"
rowseparator: "\n"
stats: off
width:

可用select查询app_info表,并删除想要删除的记录,然后重启系统,通知中的应用标签消失。

参考&鸣谢