Skip to main content

Notifications

You can configure your plugin to send notifications (Email, Mobile Push or Browser Push).

Prerequisites#

  1. You must own a plugin and have it installed on a subscription. You can find more information about this topic on the Distribute the Plugin page.
  2. You must also have a Notification Api Key. You can read about acquiring one on the Api Keys page.

Configuration#

To configure a notification for your plugin you have to make some changes in your definition.json file. You have to add a new property called notifications that accepts an array of objects. Each object represents a Plugin Notification Definition. A plugin notification definition consists of the following properties:

PropertiesTypeDescription
keyrequiredstringA unique key that we use for identifying this notification definition.
titlerequiredstringThe default title that will show up for users in the notification settings page.
possibleNotificationTypesrequired[string]The type of notifications your plugin supports. We support any combination of: "MobilePush", "BrowserPush", "Email".
titleTranslationsdefault nullDictionary<string, string>Optional translations for the title. Key represents the language code (ex. en or de) and value the actual translation in that language.
descriptiondefault nullstringOptional description of the notification setting.
descriptionTranslationsdefault nullDictionary<string, string>Optional translations for the description. Comparable to the title translations.

Example#

{
"pluginId": "MyPlugin",
// ...
"notifications": [
{
"key": "my-plugin-notif-key-1",
"title": "My Plugin Notification",
"description": "You can opt-in for notification about My Plugin.",
"titleTranslations": {
"de": "Meine Plugin-Benachrichtigung",
"ko": "๋‚ด ํ”Œ๋Ÿฌ๊ทธ์ธ ์•Œ๋ฆผ"
},
"descriptionTranslations": {
"de": "Sie kรถnnen sich fรผr Benachrichtigungen รผber My Plugin entscheiden.",
"ko": "๋‚ด ํ”Œ๋Ÿฌ๊ทธ์ธ์— ๋Œ€ํ•œ ์•Œ๋ฆผ์„ ์ˆ˜์‹ ํ•˜๋„๋ก ์„ ํƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค."
},
"possibleNotificationTypes": ["BrowserPush", "Email"]
}
]
}

Publishing this definition file should result in a new Notification Setting in the User Notification Settings page.

Send Notification#

In order to send a notification you have to call a specific endpoint on the Reach Api. The endpoint is formed as follows: /plugins/<pluginId>/notifications The pluginId must be the same as specified in the definition.json.

The request is a POST and it must contain the following headers:

  • Authorization: it should contain the Plugin Notification Api key generated in a previous step
  • Content-Type: it should be application/json because we expect to get a JSON as the body

The body must contain a JSON object with the following properties:

PropertiesTypeDescription
SubscriptionIdrequiredstringThe id of the target subscription. The subscription must have this plugin installed or it won't work.
TitlerequiredstringThe title of the notification.
ContentrequiredstringThe content of the notification. Will be ignored in case ContentHtml is specified.
NotificationKeyrequiredstringThis key must match the Key specified in the definition.json Plugin Notification Definition.
NotificationTypesrequired[string]The type of the notification you want to send out. We support any combination of: "MobilePush", "BrowserPush", "Email". The values used must be a subset of the PossibleNotificationTypes defined in the definition.json. If a user decided to opt-out they won't receive that type of notification.
GroupIdsdefault null[string]GroupIds or UserIds (or both) must be specified. These will be used to target the recipients of the notifications. To obtain a groupId go the Groups section in the Settings inside Reach and click on the Permission assignment of a group you would like to add. Next copy the groupId from the url.
UserIdsdefault null[string]GroupIds or UserIds (or both) must be specified. These will be used to target the recipients of the notifications. One can find their userId on the About page in Reach.
ContentHtmldefault nullstringHTML snippet that will replace Content if specified.
Urldefault nullstringIf set will render an Open in Reach button navigating to this url.

Example#

{
"Method": "POST",
"Headers": {
"Authorization": "Bearer <Plugin-Notification-Api-Key>",
"Content-Type": "application/json"
},
"Body": {
"GroupIds": [
// ...
],
"UserIds": [
// ...
],
"Title": "Important announcement!",
"Content": "We won't hold any meetings tomorrow!",
"NotificationTypes": ["Email", "BrowserPush"],
"NotificationKey": "my-plugin-notif-key-1",
"SubscriptionId": "a95de2ad-46bb-41e8-af99-5692132ca350",
// If specified "Content" will be ignored
"ContentHtml": "<h1>Important announcement!</h1> <br /> <p>We won't hold any meetings tomorrow!</p>",
"Url": "https://reach.livetiles.io/"
}
}

Email#

Browser Push#