Getting started with Notification Center

This document describes how to start building apps that work with OpenFin Notification Center. It tells you everything you need to do to generate your first notification from your app.

Prerequisites

You need access to the following to get started:

  1. The OpenFin runtime used by the Notification Center app: Each version of the Notification Center app lists its required runtime version in its release notes on the OpenFin Versions page.
  2. The OpenFin Notification Center app itself: You don’t need to download anything manually; so long as you can access the OpenFin CDN, the app installs itself. If you can’t access the CDN, please refer to the self-hosting section in the Deploying OpenFin Notification Center in an enterprise documentation.
  3. Optionally but ideally, the npm library for OpenFin Notification Center. This library is required to communicate with the Notification Center app. Although the library is not essential, OpenFin strongly recommends it.

Prepare your app

Do the steps described in one of the following sections to prepare your app to use notifications. The recommended approach is to install the npm library. Alternatively, you can include the library via a script element. Use of the notifications service is deprecated.

Install the library

Once you have the items listed in the Prerequisites section, add the npm library to your OpenFin app.

npm install openfin-notifications

The npm library is updated only when the API is changed, so the version number in the npm registry might not match the latest released version of the Notification Center app. For purposes of getting started, just use the latest version.

📘

Note

Updating the npm library does not update the version of the Notification Center app.

Optional: Use a script element

If, for some reason, you are unable to use the npm repository, you can include the npm library for Notification Center via a script element in HTML.

<script src="https://cdn.openfin.co/services/openfin/notifications/<VERSION>/openfin-notifications.js"></script>

OpenFin recommends that you use the library from the npm repository, but we also support this method to access it.

Deprecated: Use the notifications service

If you are still targeting an older version of the RVM (< 6.0), the Notification Center app must be launched with a special value in the OpenFin manifest.

🚧

Warning

Use of the notification service is deprecated and OpenFin plans to stop supporting it in 2021.

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

Create your first notification

Once your app has the client library installed, you can create a notification. Copy and paste the following code into your app, and call it.

import {create} from 'openfin-notifications';

create({
    title: 'Hello!',
    body: 'This is your first notification',
    category: 'hello',
})

Did this page help you?