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:
- The Notification Service, displaying and managing notifications and owning the Notification Center UI
- The Notification Client, exposing API's for applications to create and manage notifications
- OpenFin version >= 8.56.30.42
- RVM >= 4.2.0.33
- Create notifications
- Clear/dismiss notifications
- Attach handlers for click/close events
- Persist notifications in the Notification Center
- 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
Using the notifications service is done in two steps, add the service to application manifest and import the API:
To ensure the service is running, you must declare it in your application config.
"services": [
{
"name": "notifications"
}
]
To use the API, you must first include it in your application.
npm install openfin-notifications
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 UIclearAll()
Clears all notifications sent from the applicationaddEventListener(eventName: String, handler: Function)
Application global event listener invoked when the use clicks the event, or button on the event
NotificationOptions {
body: string;
title: string;
subtitle: string;
icon: string;
context: NotificationContext;
date: Date;
buttons: OptionButton[];
inputs: OptionInput[];
}
This is a WIP. Items on our immediate roadmap include:
- Support for buttons/links
- Inline reply
- Configuration
- Support for Types/templates
- Remote notifications
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.
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
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
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
This project uses the Apache2 license
This is an open source project and all are encouraged to contribute. Please enter an issue in the repo for any questions or problems. For further inqueries, please contact us at support@openfin.co