A node.js lib to access the Apple Notification Center Service (ANCS)
forked from (https://github.com/sandeepmistry/node-ancs)
checkout repository inside node_modules folder
- bleno/noble Gatt Server reference
/* setup bleno/noble before! */
var ANCS = require('ancs');
var ancsClient = new ANCS(noble);
Startup
ancsClient.discoverServicesAndCharacteristics(function(){
/* ready to be used */
....
});
Notification Events
ancs.on('notification', function(notification) {
...
});
- notification has the following properties
- event (one of):
- added
- modified
- removed
- flags (array):
- silent
- important
- category (one of):
- other
- incomingCall
- missedCall
- voicemail
- schedule
- other
- news
- healthAndFitness
- businessAndFinance
- location
- entertianment
- categoryCount
- uid
- event (one of):
Operations for 'added' or 'modified' notifications (event property)
Read App Identifier
notification.readAppIdentifier(function(appIdentifier) {
...
});
Read Title
notification.readTitle(function(title) {
...
});
Read Subtitle
notification.readSubtitle(function(subtitle) {
...
});
Read Message
notification.readMessage(function(message) {
...
});
Read Date
notification.readDate(function(date) {
...
});
Read All Attributes
notification.readAttributes(function(attributes) {
...
});
- attributes has the following properties
- appIdentifier
- title
- subtitle
- message
- date
- positiveAction
- negativeAction
Application operations
Get app display name
var app = ancsClient.getApp(notification.appIdentifier);
if( app.displayName == null ) {
app.readAttributes(function(){
/* attributes available */
});
}
- application attributes are
- displayName
Performing notification actions
Perform positive action
notification.performPositiveAction();
Perform negative action
notification.performNegativeAction();