MacOS – Remove dock notification badge for apps not in notification center

macosnotifications

For nuisance apps that set a badge notification icon, but which are not in the Settings Notifications center, is there a way to block the badge icon?

Spotify, for example, creates a notification for every insignificant event, with no way of blocking it in app.

Personally I don't understand how apps are allowed to show a badge icon without being in the Notifications center in the first place.

Example:

enter image description here

Best Answer

I have a solution that I was able to reverse engineer. I've tested it on my machine, running Yosemite 10.10.4 (14E46). If you can find the bundle ID (in the Info.plist file for the app bundle), you can use this script to force the app to appear in the notifications preferences pane.

# "Usernoted" seems to be the "user notifications daemon", so get it's PID.
pid=$(ps aux | grep -i [u]sernoted | awk '{print $2}')

# Find the sqlite3 database that this program has open. It's in a "private" folder (app sandboxing).
db="$(lsof -p $pid | grep com.apple.notificationcenter/db/db\$ | awk '{print $9}')"

# I got the bundleid from Spotify.app/Contents/Info.plist
bundleid="com.spotify.client"

# I use 0 as the flags because you can change all the settings in System Preferences
# 5 seems to be the default for show_count
# Grab the next-highest sort order
sql="INSERT INTO app_info (bundleid, flags, show_count, sort_order) VALUES ( '$bundleid', 0, 5, (SELECT MAX(sort_order) + 1 FROM app_info) );"

# Run the command
sqlite3 "$db" "$sql"

# Restart usernoted to make the changes take effect
killall usernoted

At this point you can open System Preferences -> Notifications, and you will find the app that you just added at the bottom of the list. You can enable / disable badging the icon from this page.