https://github.com/sidneys/notificationcenter-settings-macos
Exposes a streamlined interface to the Notification Center settings for macOS applications.
https://github.com/sidneys/notificationcenter-settings-macos
Last synced: 4 months ago
JSON representation
Exposes a streamlined interface to the Notification Center settings for macOS applications.
- Host: GitHub
- URL: https://github.com/sidneys/notificationcenter-settings-macos
- Owner: sidneys
- Created: 2016-07-10T22:26:05.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-13T11:08:28.000Z (almost 10 years ago)
- Last Synced: 2025-09-20T08:22:41.447Z (9 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# notificationcenter-settings-macos
[](https://gitter.im/sidneys/notificationcenter-settings?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://github.com/sidneys/notificationcenter-settings-macos/issues)
---
**Exposes a streamlined interface to the [Notification Center](https://en.wikipedia.org/wiki/Notification_Center) settings for OSX / macOS applications.**
---
## Contents
1. [Platforms](#platforms)
1. [Programmatic Usage](#programmatic-usage)
1. [Commandline Interface](#commandline-interface)
1. [API](#api)
1. [Tests](#tests)
1. [Under the Hood](#under-the-hood)
1. [Author](#author)
- Tested on Yosemite, El-Capitan and Sierra (10.10 upward).
Install it
```bash
$ npm install --save notificationcenter-settings
```
Require it
```js
var ncSettings = require('notificationcenter-settings');
```
Use the **get()** callback to parse settings:
```js
ncSettings.get('com.apple.iTunes', function(err, result) {
if (err) return err;
console.dir(result);
};
```
Result:
```
{
isHidden: false,
showBadge: true,
playSound: true,
isBanner: true,
isAlert: false,
hideInLockscreen: false,
showPreview: false,
hidePreview: false
}
```
Install the module globally:
```bash
npm install --global notificationcenter-settings
```
Run the provided **nc-settings** executable:
```bash
$ nc-settings com.apple.iTunes
```
Result:
```bash
Notification Center settings for "com.apple.iTunes":
{
"isHidden": false,
"showBadge": true,
"playSound": true,
"isBanner": true,
"isAlert": false,
"hideInLockscreen": false,
"showPreview": false,
"hidePreview": false
}
```
### `get(bundleId, callback)`
Get current Notification Center settings for app using bundleId.
- **String *bundleId* - Bundle identifier for the callback function**
- **Function *callback* - The function to call to start Notification Center parsing**
**Returns:**
- *Object* with the following properties:
- isHidden **Show in Notification center**
- showBadge **Show badge app icon**
- playSound **Play sound for notifications**
- isBanner **Show as banner**
- isAlert **Show as alert**
- hideInLockscreen **Hide notifications on lock screen**
- showPreview **Show message preview**
- hidePreview **Hide message preview**
### `path()`
Get absolute path to Notification Center database file.
*See also ['Getting the bundle identifier of an OS X application in a shell script'](http://superuser.com/questions/346369/getting-the-bundle-identifier-of-an-os-x-application-in-a-shell-script)*
**Returns:**
* *String* containing the absolute path to the database file
```bash
npm test
```
## Under the hood
The module parses the default Sqlite3 .db database for **com.apple.notificationcenter**.
The contained bit flags for each application identifier contain its current settings.
[Sidney Bofah](http://sidneys.github.io)
Thanks goes to the [NCUtil](https://github.com/jacobsalmela/NCutil) project for laying out the baseline implementation in Python.
## Badge
[](https://www.npmjs.com/package/notificationcenter-settings)