1. API
  2. notification

API

Functions

Function Description
close({ ref }) Dismisses a notification that was shown to the user
create(options) Creates a new Notification.
getActions({ ref, }) Retrieves the actions of the notification.
getBody({ ref }) Retrieves the body of the notification.
getCloseButtonText({ ref, }) Retrieves the close button text of the notification.
getHasReply({ ref }) Retrieves whether the notification has a reply action.
getReplyPlaceholder({ ref, }) Retrieves the reply placeholder of the notification.
getSilent({ ref }) Retrieves whether the notification is silent.
getSound({ ref }) Retrieves the sound of the notification.
getSubtitle({ ref }) Retrieves the subtitle of the notification.
getTimeoutType({ ref }) Retrieves the type of timeout duration for the notification. Can be "default" or "never". Linux and Windows only.
getTitle({ ref }) Retrieves the title of the notification.
getToastXml({ ref }) Retrieves the Toast XML of the notification.
getUrgency({ ref }) Retrieves the urgency of the notification. Can be "normal", "critical", or "low". Linux only.
show({ ref }) Shows a notification to the user

close()

Dismisses a notification that was shown to the user

Signature:

        import { notification } from "@todesktop/client-core"
notification.close({ ref }: {
    ref: Ref;
}): Promise<void>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<void>

create()

Creates a new Notification.

Signature:

        import { notification } from "@todesktop/client-core"
notification.create(options: NotificationConstructorOptions): Promise<Ref>;

      
Parameters
Parameter Type Description
options NotificationConstructorOptions Notification constructor options.

Returns:

Promise<Ref>

Identifier for the newly created Notification.

getActions()

Retrieves the actions of the notification.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getActions({ ref, }: {
    ref: Ref;
}): Promise<NotificationAction[]>;

      
Parameters
Parameter Type Description
{ ref, } { ref: Ref; }

Returns:

Promise<NotificationAction[]>

string.

getBody()

Retrieves the body of the notification.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getBody({ ref }: {
    ref: Ref;
}): Promise<string>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<string>

string.

getCloseButtonText()

Retrieves the close button text of the notification.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getCloseButtonText({ ref, }: {
    ref: Ref;
}): Promise<string>;

      
Parameters
Parameter Type Description
{ ref, } { ref: Ref; }

Returns:

Promise<string>

string.

getHasReply()

Retrieves whether the notification has a reply action.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getHasReply({ ref }: {
    ref: Ref;
}): Promise<boolean>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<boolean>

boolean.

getReplyPlaceholder()

Retrieves the reply placeholder of the notification.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getReplyPlaceholder({ ref, }: {
    ref: Ref;
}): Promise<string>;

      
Parameters
Parameter Type Description
{ ref, } { ref: Ref; }

Returns:

Promise<string>

string.

getSilent()

Retrieves whether the notification is silent.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getSilent({ ref }: {
    ref: Ref;
}): Promise<boolean>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<boolean>

boolean.

getSound()

Retrieves the sound of the notification.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getSound({ ref }: {
    ref: Ref;
}): Promise<string>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<string>

string.

getSubtitle()

Retrieves the subtitle of the notification.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getSubtitle({ ref }: {
    ref: Ref;
}): Promise<string>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<string>

string.

getTimeoutType()

Retrieves the type of timeout duration for the notification. Can be "default" or "never". Linux and Windows only.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getTimeoutType({ ref }: {
    ref: Ref;
}): Promise<string>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<string>

string.

getTitle()

Retrieves the title of the notification.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getTitle({ ref }: {
    ref: Ref;
}): Promise<string>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<string>

string.

getToastXml()

Retrieves the Toast XML of the notification.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getToastXml({ ref }: {
    ref: Ref;
}): Promise<string>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<string>

string.

getUrgency()

Retrieves the urgency of the notification. Can be "normal", "critical", or "low". Linux only.

Signature:

        import { notification } from "@todesktop/client-core"
notification.getUrgency({ ref }: {
    ref: Ref;
}): Promise<string>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<string>

string.

show()

Shows a notification to the user

Signature:

        import { notification } from "@todesktop/client-core"
notification.show({ ref }: {
    ref: Ref;
}): Promise<void>;

      
Parameters
Parameter Type Description
{ ref } { ref: Ref; }

Returns:

Promise<void>

Variables

Variable Description
on Subcribes to an event on a notification object.
removeAllListeners Unsubscribes all notification objects from the event name.

on

Subcribes to an event on a notification object.

Signature:

        on: <E extends "close" | "show" | "click" | "action" | "failed" | "reply">(eventName: E, callback: NamespaceEvents<{
    action: (index: number) => void;
    click: () => void;
    close: () => void;
    failed: (error: string) => void;
    reply: (reply: string) => void;
    show: () => void;
}>[E], { ref, preventDefault }?: {
    ref?: import("@todesktop/client-util").InstanceRefObject;
    preventDefault?: boolean;
}) => Promise<() => Promise<void>>

      

removeAllListeners

Unsubscribes all notification objects from the event name.

Signature:

        removeAllListeners: <E extends "close" | "show" | "click" | "action" | "failed" | "reply">(eventName: E, { ref, }?: {
    ref?: import("@todesktop/client-util").InstanceRefObject;
}) => Promise<void>

      

Type Aliases

NotificationEvents

Signature:

        export declare type NotificationEvents = NamespaceEvents<{
    action: (index: number) => void;
    click: () => void;
    close: () => void;
    failed: (error: string) => void;
    reply: (reply: string) => void;
    show: () => void;
}>;

      
Type Alias Description
NotificationEvents