Skip to content

bryangaleopenfin/notifications-service

 
 

Repository files navigation

OpenFin Notifications

Overview

OpenFin Notifications provide developers with a uniform way to create, display and organize desktop notifications as well as responding to notification events (notification clicked, closed etc.)

Notifications will be displayed as toasts as well as being listed and organized in a notification center. The Notification Center can be accessed by clicking on the system tray notification icon.

OpenFin Notifications uses the new Services framework to expose its API to consuming applications. You can see the documentation for these APIs here: http://cdn.openfin.co/jsdocs/alpha/fin.desktop.Service.html.

This project consist of 2 parts:

  1. The Notification Service, displaying and managing notifications and owning the Notification Center UI
  2. The Notification Client, exposing API's for applications to create and manage notifications

Dependencies

  • OpenFin version >= 8.56.30.42
  • RVM >= 4.2.0.33

Features

  • Create notifications
  • Clear/dismiss notifications
  • Attach handlers for click/close events
  • Persist notifications in the Notification Center

Run Locally

  • To run the project locally the npm scripts require git bash.
  • Windows support only.
  • Node 8.11 LTS.
npm install
npm run build:dev
npm run start

Getting Started

Using the notifications service is done in two steps, add the service to application manifest and import the API:

Manifest declaration

To ensure the service is running, you must declare it in your application config.

"services": [
    {
        "name": "notifications"
    }
]

Import the API

To use the API, you must first include it in your application.

npm install openfin-notifications

API Documentation

  • create(id: String, options: NotificationOptions) Creates a notification and sends it to the Notifications manager Promise resolves to ID of notification created.
  • getAll() Promise resolves to all notifications sent by the App to Notification manager that are still active (not cleared)
  • clear(id: String) Clears the notification from the Notification Center UI
  • clearAll() Clears all notifications sent from the application
  • addEventListener(eventName: String, handler: Function) Application global event listener invoked when the use clicks the event, or button on the event

Notification Config Options

NotificationOptions {
    body: string; 
    title: string;
    subtitle: string;
    icon: string;
    context: NotificationContext;
    date: Date;
    buttons: OptionButton[];
    inputs: OptionInput[];
}

Roadmap

This is a WIP. Items on our immediate roadmap include:

  • Support for buttons/links
  • Inline reply
  • Configuration
  • Support for Types/templates
  • Remote notifications

Known Issues

If notifications are persisted and the source application is restarted, all events will still be sent to the source application for handling along with the original context. It is up to these applications to handle these events as they see fit.

Project Structure

All code lives under the src directory which can be broken down into 5 areas: client, demo, provider, test and ui.

  • src
  • client - the service client
  • demo - the demo config/html (for testing the service itself)
  • provider - the service provider
  • test - all the tests
  • ui - the notification center ui

Project Helpers

We use a handful of NPM scripts to handle most of the typical tasks in a project like compile, stage, run, etc.

  • build - run webpack in prod mode
  • build:dev - run webpack in dev mode
  • check - runs gts check
  • clean - runs gts clean
  • compile - runs tsc on client/provider
  • docs - builds type docs
  • fix - runs gts fix
  • start - runs local server, serves locally compiles/packed files
  • test - runs all project tests

Build

The project is built and staged to the ./build directory. This directory is exactly what would be deployed to the production CDN.

  • build
  • client.js - the compiled service client
  • demo/ - the demo files
  • provider.js - the compiled service provider
  • ui - the compiled notification center UI
    • pack - bundled files for the UI

License

This project uses the Apache2 license

However, if you run this code, it may call on the OpenFin RVM or OpenFin Runtime, which are covered by OpenFin's Developer, Community, and Enterprise licenses. You can learn more about OpenFin licensing at the links listed below or just email us at support@openfin.co with questions.

https://openfin.co/developer-agreement/ https://openfin.co/licensing/

Support

This is an open source project and all are encouraged to contribute. Please enter an issue in the repo for any questions or problems. Alternatively, please contact us at support@openfin.co

About

Notifications Desktop Service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 74.3%
  • CSS 17.1%
  • JavaScript 4.3%
  • HTML 4.2%
  • Gherkin 0.1%