/** * Core notification features. * * @module BaseNotificationOptions */ /** * imports */ import { NotificationStream, NotificationIndicator, NotificationIndicatorWithCustomColor, ButtonOptions, ActionDeclaration, ActionNoop, ActionBodyClick, CustomData, NotificationSoundOptions } from '../main'; import { TemplateNames } from './templates'; /** * Configuration options for constructing a Notifications object, shared between all templates. */ export interface BaseNotificationOptions { /** * A unique identifier for the notification. * * If not provided at time of creation, one will be generated for you and returned as part of the {@link create} method. */ id?: string; /** * Template of the notification payload. */ template: T; /** * Title of the notification. * * Displayed as the first line of the notification, in a heading style. */ title: string; /** * If set to false, the user won't be able to set a reminder for this notification in the Notification Center. * * Default value is `true`. */ allowReminder?: boolean; /** * Describes the context of this notification. Allows users to control different notification types that are raised * by an application. * * This string is not displayed on the notification itself, but should be user-readable. It will be displayed in * the Notification Center preferences section, and any string passed as a `category` should make sense when * displayed in that context. * * Event categories should list all the different types of notifications raised by your app. As a general guide, if * a user may want to have different preferences for some subset of notifications created by your app, then * applications should ensure that those notifications have a distinct category. * * @deprecated This property is deprecated and will be removed in a future release. */ category?: string; /** * Add a semantic visual indicator to a notification, to signal to the user the nature of the event that they are * being notified about. * * This should not be treated as a priority. */ indicator?: NotificationIndicator | NotificationIndicatorWithCustomColor | null; /** * URL of the icon to be displayed in the notification. */ icon?: string; /** * Application-defined context data that can be attached to buttons on notifications. * * When using forms, form data submitted will be written to `customData` and returned to your app by * listening to the submit {@link NotificationActionEvent|`notification-action`} with the trigger {@link ActionTrigger.SUBMIT|submit}. */ customData?: CustomData; /** * The timestamp shown on the notification. If omitted, the current date/time will be used. * * This is presentational only - a date in the future does not incur a scheduling action. */ date?: Date; /** * The expiry date and time of the notification. If specified, the notification will be removed at this time, or as * soon as possible after. If not specified, the notification will never expire, and will persist until it * is closed. */ expires?: Date | null; /** * When set to `sticky` this settings enables the notification toast to stay visible on the desktop * until the user interacts with it. When set to `transient` the toasts will follow the default behavior * of fading away after a short duration. When set to `none` the toasts will not appear and the notification * will only appear in the Notification Center. * * This property has a precedence over `sticky` propery. * */ toast?: 'sticky' | 'transient' | 'none'; /** * @deprecated * * This property is deprecated. Use `toast` instead. */ sticky?: 'sticky' | 'transient'; /** * A list of buttons to display below the notification text. * * Notifications support up to four buttons. Attempting to add more than four will result in the notification * being rejected by the service. */ buttons?: ButtonOptions[]; /** * Notification Stream * * If the notification belongs to a stream, the user will be able to group notifications by stream. */ stream?: NotificationStream | null; /** * Id of the platform this notification belongs to. * * If the application belongs to a platform, the user interaction with the notification will be dispatched * back to the platform provider. */ platform?: string | null; /** * An {@link NotificationActionResult|action result} to be passed back to the application inside the * {@link NotificationActionEvent|`notification-action`} event fired when the notification is clicked. * * This action will only be raised on clicks to the notification body. Interactions with buttons (both * application-defined buttons, and the default 'X' close button) or with actionable fragments will not trigger a * {@link ActionTrigger.SELECT|select} action. * * See {@link Actions} for more details on notification actions, and receiving action events from notifications. */ onSelect?: (ActionDeclaration & ActionNoop & ActionBodyClick) | null; /** * An {@link NotificationActionResult|action result} to be passed back to the application inside the * {@link NotificationActionEvent|`notification-action`} event fired when the notification the expires. * * If `expires` is specified for the notification, this action will be raised when the notification expires. If * `expires` is not specified for the notification, this action will never be raised. Note that if an `onClose` * action result is also specified, both actions will be raised if and when the notification expires. * * See {@link Actions} for more details on notification actions, and receiving action events from notifications. */ onExpire?: ActionDeclaration | null; /** * An {@link NotificationActionResult|action result} to be passed back to the application inside the * {@link NotificationActionEvent|`notification-action`} event fired when the notification is closed. * * This action is raised regardless of how the notification is closed, whether from user interaction, expiration, * or programmatic removal -- such as a call to `clear`. * * See {@link Actions} for more details on notification actions, and receiving action events from notifications. */ onClose?: ActionDeclaration | null; /** * A priority for this notification. It's from 1 - 4. */ priority?: number; /** * Sound options for a notification. */ soundOptions?: NotificationSoundOptions; }