Connect a Workspace Platform to Notification Center
Starting in Workspace 6.3, the Notification Center application supports multiple Workspace Platform applications existing side by side on a user's desktop. The user can select a specific Workspace Platform app within Notification Center, in order to see notifications only from the applications running within that Workspace Platform. The selected platform also applies its theme to its notifications and to the Notification Center app.
Workspace Platforms in the Notification Center application
When a Workspace Platform app registers with Notification Center, an icon for that Workspace Platform appears within the Notification Center app. If the user clicks the icon, the Notification Center app displays only notifications from that Workspace Platform. If multiple Workspace Platforms are registered, the user can select among them by clicking their respective icons. Clicking a Workspace Platform's icon also switches the Notification Center app to use that Workspace Platform's theme, if one is defined; if a theme is not defined for the Workspace Platform, the default theme is used.
An All icon displays all notifications, including any from notification providers that are not Workspace Platforms, and applies the default theme. The current selection (All or a Workspace Platform) is indicated by an underline beneath the selected icon.
If the Notification Center app is launched from a particular Workspace Platform, then that application's theme, icon, and filter are automatically selected. If the Notification Center app is launched independently of a Workspace Platform, then the default theme and All icon are selected, with no platform filter applied; the Workspace Platform applications available are those that are already running when the Notification Center app starts.
The theme applied by a Workspace Platform when invoking the Notification Center app is the same one it applies to all Workspace components; in this way, the colors are consistent across all Workspace components themed by the same Workspace Platform, with nothing unique to Notification Center.
Workspace Platform selection and toasts
Although selecting a particular Workspace Platform application within the Notification Center application filters the notifications that are shown there, this selection has no effect on the creation and display of notification toasts. All toasts generated by all notification providers are displayed on the desktop, regardless of the selected Workspace Platform in the Notification Center app.
Notification toasts inherit the theme of the Workspace Platform that generates them. Toasts generated by notification providers that are not Workspace Platforms use the default theme for the desktop.
Register a Workspace Platform with Notification Center
If you have already created a Workspace Platform application, for example, to provide content to Store or commands and search results to Home, then exposing it in Notification Center is relatively straightforward.
The following discussion assumes that you have already initialized a Workspace Platform, optionally with a color theme. You can then register it with Notification Center via the following steps:
-
Import the Notification Center API via the Workspace SDK.
-
Define the information about the Workspace Platform needed by Notification Center.
-
A unique identifier
-
A user-friendly title
-
A URL for an icon
-
-
Register the Workspace Platform with Notification Center.
-
Create notifications in your application, same as any other notification provider.
-
When the Workspace Platform no longer needs to appear in the Notification Center (such as on exit), deregister it.
Import the Notification Center API via the Workspace SDK
You do not need to separately import both the Notification Center API and the Workspace API. You can access the Notification Center API via the Workspace SDK:
import * as Notifications from "@openfin/workspace/notifications";
import type { NotificationsPlatform } from "@openfin/workspace/notifications";
Define and register the Workspace Platform application
// Import as above
const platform: NotificationsPlatform =
{
id: "UNIQUE-PROVIDER-ID",
title: "Custom Notification Platform",
icon: "https://example.com/favicon.ico",
};
Notifications.registerPlatform(platform);
You do not need to explicitly pass the theme when registering with Notification Center, given that you are registering an application that already has a Workspace Platform theme defined.
Create notifications
Refer to Get started with Notification Center and related articles for information about features you can use when creating notifications.
Deregister the Workspace Platform
//On some event, etc., it's time to deregister
Notifications.deregister("UNIQUE-PROVIDER-ID");
Updated 11 months ago