Skip to content

A node.js lib to access the Apple Notification Center Service (ANCS)

License

Notifications You must be signed in to change notification settings

brunowonka/node-ancs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ancs

A node.js lib to access the Apple Notification Center Service (ANCS)

forked from (https://github.com/sandeepmistry/node-ancs)

Install

checkout repository inside node_modules folder

Prerequisites

  • bleno/noble Gatt Server reference

Usage

/* 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
      • email
      • other
      • news
      • healthAndFitness
      • businessAndFinance
      • location
      • entertianment
    • categoryCount
    • uid

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();

About

A node.js lib to access the Apple Notification Center Service (ANCS)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%