3

MAC OS X has settings per application and you can turn on Do Not Disturb Mode just for a specific one: https://www.reddit.com/r/apple/comments/2r0bji/do_not_disturb_mode_in_os_x_when_using_a_specific/

Also...there is a way to detect the DND mode set for the whole system, based on this: Programmatically check state of do not disturb on OS X

But is there any API that would allow me to do a check per application and see if it has DND enabled or not?

1 Answers1

5

There is no per-app Do Not Disturb in macOS.

The closest you're probably going get to this is retrieving the enabledRemoteNotificationTypes method of NSApplication

This returns a NSRemoteNotificationType value, which contains a bitmask whose values indicate the types of push notifications that the app requested.

The possible values are:

NSRemoteNotificationTypeNone - The app should not display a badge.

NSRemoteNotificationTypeBadge - The app should display a badge.

NSRemoteNotificationTypeSound - The app should play a sound.

NSRemoteNotificationTypeAlert - The app should display an alert.

This is only going to be useful for the current running app and you can get more info from the Apple Developer site

Another potential place to look:

You can find the SQLite database that NotificationCenter uses at in following directory: getconf DARWIN_USER_DIR + /com.apple.notificationcenter/db, however do be careful, as mine wasn't in /db, the latest version was in /db2

Prior to Yosemite, this file was located at ~/Library/Application\ Support/NotificationCenter/

I haven't gone through this database so I can't tell you whether or not applicable settings reside here, but it's a good place to start looking.

If you're publishing your app on the App Store, you probably won't be able to use this method because of sandboxing, but it's worth a try either way.

Will Jones
  • 1,861
  • 13
  • 24