Skip to main content
Module

x/deno_notify/ts/mod.ts>Notification

✉️ Send desktop notifications on all platforms in Deno
Latest
class Notification
import { Notification } from "https://deno.land/x/deno_notify@1.4.3/ts/mod.ts";

Constructors

new
Notification(unnamed 0?: { macos?: MacOS; windows?: Windows; linux?: Linux; }, strictSupport?: boolean)

Create a Notification. Most fields are empty by default.

Platform specific-features are locked behind the supports parameter.

Type Parameters

optional
MacOS extends boolean = false
optional
Windows extends boolean = false
optional
Linux extends boolean = false

Properties

private
_body: string | null
private
_icon: string | null
private
_soundName: string | null
private
_subtitle: string | null
private
_timeout: { type: "Never"; } | { type: "Milliseconds"; value: number; } | null
private
_title: string | null
body: (body: string) => this

Set the body. Available on all platforms.

Multiline textual content of the notification. Each line should be treated as a paragraph. Simple html markup may be supported on some platforms.

Clone the notification into a separate instance, maintaining all the properties.

icon

Set the icon. Available on Linux.

Can either be a file:// URI, or a common icon name, usually those in /usr/share/icons can all be used (or freedesktop.org names).

show: () => unknown

Display the notification to the user.

soundName: (soundName: MacOS extends true ? MacSoundNames : string) => this

Set the soundName to play with the notification.

With macOS support, a list of default sound names is provided.

readonly
strictSupport: boolean

Whether or not to error if a feature is called on an operating system that does not support it.

subtitle

Set the subtitle. Available on macOS and Windows.

For more elaborate content, use the body field.

readonly
supports: { macos: MacOS; windows: Windows; linux: Linux; }

Which platform-specific features to support in this notification.

timeout

Set the timeout. Available on Windows and Linux.

This sets the time (in milliseconds) from the time the notification is displayed until it is closed again by the Notification Server.

Setting this to 'never' will cause the notification to never expire.

title: (title: string) => this

Set the title. This is a required field. Available on all platforms.

For more elaborate content, use the body field.