Register a notifications platform
The HERE notification center requires you to register() your notification platform before you can work with the client library.
This method enables you to configure and connect to your notification platform.
You can use the HERE CDN, or you can self-host.
The @openfin-notifications and @openfin/workspace/notifications packages are deprecated, and will no longer be supported in a future release.
The @openfin/notifications package takes the place of both.
We recommend working with the default Runtime version for your version of Notification Center. This is the version we test against.
Use the HERE CDN
npm install @openfin/notifications
import { connect, create } from "@openfin/notifications";
// connect to the notification center.
await register();
// call api methods...
await create(notificationOptions);
Host on your server (optional)
Get the Notification Service package:
-
Download the Notifications Service package from the HERE Versions page.
-
Unzip the package, and host the contents over HTTPS on your server.
-
In your manifest, include the location of the
provider.htmlfile 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 the manifest for Notification Center hosted by HERE. Make sure to replace all values with values for your environment:{
...
"offlineAccess": true,
"startup_app": {
"name": "Private-Virtual-Notifications-2",
"description": "HERE Core UI 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 HERE CDN, at
https://resources.here.io/services/openfin/notifications/VERSION/app.jsonand modify only the URL and UUID if you don't require additional customization. This approach guarantees the correct Runtime version.
Registration with @openfin/notifications
When using the @openfin/notifications package (recommended for HERE Core v43 and later), each Notification Center runs on its own notifications platform.
If you self-host multiple notification platforms, this ensures that each Notification Center receives only its own notifications.
Notifications platform configuration is handled by the platform manifest. The client library reads routing and isolation settings directly from the manifest, so you no longer need to pass your self-hosted notifications provider config as options to register().
import { register, create } from "@openfin/notifications";
register();
const exampleNotification: BaseNotificationOptions =
{
// banner at the top of the notification
indicator:
{
color: 'orange',
text: 'News Alert',
},
icon: 'https://EXAMPLE.COM/examples/notifications/company-B.png', //optional
title: 'US added 138K jobs; Lower than target 185K', // required
// TemplateMarkdown
body: 'After more than a decade of growth, U.S. nonfarm payrolls shrunk by 701,000, and the unemployment rate rose to 4.4%...',
// simple button
buttons:
[
{
title: “Read More”,
type: “button”,
cta: true,
// see main article on buttons for more complex actions you can invoke with a button
// this is the simplest possible example, provides only an informational link
onClick:
{
window.open("https://EXAMPLE.COM/news/employment”, "_blank")
}
}
]
// optional, disable to support custom sounds
soundOptions:
{
mode: 'silent'
}
};
create(exampleNotification);
Registration prior to HERE Core UI v43
In versions earlier than HERE Core v43, you can provide one or more notifications provider definitions to the register() method.
import { register, create } from "@openfin/notifications";
import type { NotificationsRegisterOptions } from "@openfin/notifications";
// define notifications provider -- a HERE Core UI 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 service hosted by HERE
// 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);