Register your notifications platform

In Notifications v2 or later, you must register your platform. This function lets you control when Notification Center starts on users' desktops.

In Notifications v2.4 or later, you can host Notification Center on your own CDN.

How it works

In earlier versions, the register() function in @openfin/workspace/notifications let you register your Workspace platforms. In v2 or later, it is modified to take a NotificationsRegisterOptions object instead of a platform. The previous function signature is deprecated, and will no longer be supported in a future release.

📘

WARNING

The openfin-notifications package is deprecated, and will no longer be supported in a future release.

To host on your own CDN, you provide your application manifest information in a notificationsCustomManifest property of the NotificationsRegisterOptions object. You provide the location of Notification Center in your manifest. This feature is available only in Notifications v2.4 or later, with Runtime v34 or later.

We recommend working with the default Runtime version for your version of Notification Center. This is the version we test against.

How to do it

Host on your CDN (optional)

Get the Notification Service package:

  1. Download the Notifications Service package from the OpenFin Versions page.

  2. Unzip the package, and host the contents over HTTPS on your CDN.

  3. In your application manifest, include the location of the provider.html file that's included in the package. You should also include the security realm. The manifest should include settings that look something like the following example, which is modeled on OpenFin's hosted Notification Center manifest. Make sure to replace all values with values for your environment:

    {
      ...
      "offlineAccess": true,
      "startup_app": {
        "name": "Private-Virtual-Notifications-2",
        "description": "OpenFin Notification Center",
        "url": "https://PRIVATE_SERVER/NOTIFICATIONS_SERVICE_SUBDOMAIN/provider.html",
        "uuid": "MANIFEST_UUID",
        ...
        }
      },
      "runtime": {
        ...
        "arguments": "--security-realm=[REALMID]",
        "version": "34.118.78.80",
        ...
      },
      "workspace": {}
    }
    

    You can also get the default manifest from the OpenFin CDN, at https://cdn.openfin.co/services/openfin/notifications/VERSION/app.json and modify only the URL and UUID if you don't require additional customization. This approach guarantees the correct Runtime version.

Register platform

import { register, create } from "@openfin/workspace/notifications";
import type { NotificationsRegisterOptions } from '@openfin/workspace/notifications';

// define notifications provider -- a Workspace Platform in this case
const examplePlatform: options = 
{
  notificationsPlatformOptions:
  {
    id: "UNIQUE_PROVIDER_ID",
    title: "Custom Notification Platform",
    icon: "https://example.com/favicon.ico",
  },
  // optional, provide only if you host Notification Center on your CDN
  notificationsCustomManifest:
  {
    // replace these values with your own, from the application manifest
    manifestUrl: URL_OF_CUSTOM_MANIFEST,
    // UUID cannot be `notifications-service`, which is the value of the OpenFin hosted service
    // MUST match the UUID associated with `manifestUrl`
    manifestUuid: UUID_OF_CUSTOM_MANIFEST
  }
};

// explicitly register defined platform
// you can also pass the register() function without options
register(examplePlatform);

You can continue to work with the previous approach, which starts Notification Center automatically, but it is now deprecated.

import { create } from "openfin-notifications";

// create notification definitions