从通知中心删除应用程序 [英] Remove application from Notification Center

查看:106
本文介绍了从通知中心删除应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我正在制作一个小型可可粉应用程序,并在Mountain Lion中使用新的Notification Center API.但是,我的应用程序现在与日历,消息等一起显示在通知中心设置中.

Hey I was playing around with making a small cocoa application and using the new Notification Center API in Mountain Lion. However my app is now present in the notification center settings, together with Calendar, Messages and so on.

因为只有我在玩,所以我希望它现在从列表中消失,但是无论如何我都找不到将其删除的方法,尝试了几件事,将其拖出,按住alt +右键单击等等.有谁知道填充该列表的(可能是a)plist的位置?

As it was just me playing around I want it to disappear from the list now, but I cannot find anyway to remove it, tried several things, dragging it out, holding alt+right click and so on. Does anyone know where the (probably a) plist that populates that list could be located?

推荐答案

我被困在同一条船上.

虽然我不认为从Notification Center清除已注册的应用程序是有记录的步骤,但显然有一些设置可以做到这一点.这是我发现的.此数据不是存储在plist中,而是存储在sqlite数据库中.

While I don't believe purging applications from Notification Center that have once registered is a documented step, there's clearly some stuff setup to do that. Here's what I found out. This data isn't stored in a plist but rather a sqlite database.

如果您查看~/Library/Application Support/NotificationCenter/<id> (就我而言,我在NotificationCenter下只有一个目录),您会在该目录下看到一个<id>.db文件.

If you look ~/Library/Application Support/NotificationCenter/<id> (in my case, I only had one directory under NotificationCenter), you'll see an <id>.db file under the directory.

编者注: Hofi 指出自macOS 10.10起表示SQLite数据库可以在shell命令返回的目录中找到
$(getconf DARWIN_USER_DIR)com.apple.notificationcenter/db,仅命名为db.

Editor's note: Hofi points out that since macOS 10.10 said SQLite database can be found in the directory returned by shell command
$(getconf DARWIN_USER_DIR)com.apple.notificationcenter/db, named just db.

在内部查看,我看到诸如app_infoapp_sourcepresented_notifications之类的表.此外,该架构还包括一个如下所示的清理触发器:

Poking inside, I see tables like app_info, app_source, presented_notifications, etc. Furthermore, the schema includes a clean-up trigger that looks like this:

CREATE TRIGGER app_deleted AFTER DELETE ON app_info
BEGIN
    DELETE FROM scheduled_notifications     WHERE app_id=old.app_id;
    DELETE FROM presented_notifications     WHERE app_id=old.app_id;
    DELETE FROM presented_alerts                WHERE app_id=old.app_id;
    DELETE FROM notifications                   WHERE app_id=old.app_id;
    DELETE FROM app_push                        WHERE app_id=old.app_id;
    DELETE FROM app_loc                     WHERE app_id=old.app_id;
     DELETE FROM app_source                 WHERE app_id=old.app_id;
END;

如果要执行的话,请使用sqlite3客户端

Using a sqlite3 client, if you do a

select * from app_info;

第一列是应用程序的app_id,第二列是应用程序的bundleid.根据bundleid查找您的应用程序.然后做一个

the first column is the app_id of your application, the second column is your app's bundleid. Find your application based on the bundleid. Then do a

delete from app_info where app_id = <app_id>

在上面使用您的select命令找到的正确的app_id在哪里.

where is the correct app_id you found using your select command above.

令人沮丧的是,执行完此操作后,所有内容都留在NotificationCenter中(包括中心和系统偏好设置").我必须注销并重新登录才能看到更改生效,但是幸运的是,我的多个测试应用程序现在已经消失了;-)

What was frustrating was that after doing this, everything stayed around in NotificationCenter (both the center and System Preferences). I had to logout and log back in to see the changes take effect, but luckily, my multiple test apps are now gone ;-)

如果有人知道一种不那么复杂的方法,我全神贯注.

If anyone knows of a less convoluted way, I'm all ears.

这篇关于从通知中心删除应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆