# API

**Kind**: interface | **Module**: [Notifications](https://docs.interop.io/desktop/reference/javascript/notifications/index.md) | **Access**: `io.notifications`

**Source**: https://docs.interop.io/desktop/reference/javascript/notifications/api/index.html

Notifications API.

## Properties

- **`maxActions`** (`number`, required)
  The maximum number of notification actions that is supported.
- **`panel`** (`NotificationPanelAPI`, required)
  API for controlling the Notification Panel.

## Methods

### clear

Clears a notification by ID.

```ts
(id: string) => Promise<void>
```

**Parameters**

- **`id`** (`string`, required)
  ID of the notification to clear.

**Returns**: `Promise<void>`

### clearAll

Clears all notifications.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### clearMany

Clears multiple notifications using a list of IDs.

*Since: io.Connect Desktop 9.5, @interopio/desktop 6.8.0*

```ts
(notifications: string[]) => Promise<void>
```

**Parameters**

- **`notifications`** (`string[]`, required)
  List of IDs of the notifications to clear.

**Returns**: `Promise<void>`

### clearOld

Clears all notifications in the Notification Panel that the user has already seen.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### click

Clicks programmatically a notification or a notification action.

```ts
(id: string, action?: string, options?: ClickOptions) => Promise<void>
```

**Parameters**

- **`id`** (`string`, required)
  ID of the notification to click.
- **`action`** (`string`, optional)
  ID of the action to click.
- **`options`** (`ClickOptions`, optional)
  Options for the clicked notification. *Available since **io.Connect Desktop** 9.3 &@interopio/desktop 6.2.2.*

**Returns**: `Promise<void>`

### configure

Configures the global notification settings.

```ts
(options: Configuration) => Promise<void>
```

**Parameters**

- **`options`** (`Configuration`, required)
  Global notification settings.

**Returns**: `Promise<void>`

### getConfiguration

Retrieves the current global notification settings.

```ts
() => Promise<Configuration>
```

**Returns**: `Promise<Configuration>`

### getFilter

Retrieves the current filter with apps allowed or not allowed to raise notifications.

```ts
() => Promise<NotificationFilter>
```

**Returns**: `Promise<NotificationFilter>`

### import

Imports a list of notifications into the platform. Only imported notifications with state `"Active"` will be shown as notification toasts.
All imported notifications will be available in the Notification Panel. An event for raising a notification will be triggered for all imported notifications.

*Since: io.Connect Desktop 9.6, @interopio/desktop 6.9.0*

```ts
(notificationOptions: IOConnectNotificationOptions[]) => Promise<IOConnectDesktop.Notifications.NotificationData[]>
```

**Parameters**

- **`notificationOptions`** (`IOConnectNotificationOptions[]`, required)
  List of objects each describing a notification to import. The notification options for importing notifications are identical to the ones for raising a notification.

**Returns**: `Promise<IOConnectDesktop.Notifications.NotificationData[]>`

### list

Retrieves a list of objects describing all available notifications.

```ts
() => Promise<IOConnectDesktop.Notifications.NotificationData[]>
```

**Returns**: `Promise<IOConnectDesktop.Notifications.NotificationData[]>`

### onClosed

Notifies when a notification is closed.

```ts
(callback: (notification: { id: string }) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(notification: { id: string }) => void`, required)
  Callback function for handling the event.

**Returns**: `UnsubscribeFunction`

### onConfigurationChanged

Notifies when the global notification settings are changed.

```ts
(callback: (config: Configuration) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(config: Configuration) => void`, required)
  Callback function for handling the event.

**Returns**: `UnsubscribeFunction`

### onCounterChanged

Notifies when the notification counter is changed.

```ts
(callback: (info: { count: number }) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(info: { count: number }) => void`, required)
  Callback function for handling the event.

**Returns**: `UnsubscribeFunction`

### onDataChanged

Notifies when the arbitrary data associated with the notification (available in the `data` property of the notification) is changed.

*Since: io.Connect Desktop 9.1, @interopio/desktop 6.1.0*

```ts
<T>(callback: (notification: { id: string }, data: T) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(notification: { id: string }, data: T) => void`, required)
  Callback function for handling the event.

**Returns**: `UnsubscribeFunction`

### onRaised

Notifies when a new notification is raised.

```ts
(callback: (notification: IOConnectDesktop.Notifications.NotificationData) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(notification: IOConnectDesktop.Notifications.NotificationData) => void`, required)
  Callback function for handling the event.

**Returns**: `UnsubscribeFunction`

### onStateChanged

Notifies when the state of a notification is changed.

```ts
(callback: (notification: { id: string }, state: State) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(notification: { id: string }, state: State) => void`, required)
  Callback function for handling the event.

**Returns**: `UnsubscribeFunction`

### raise

Raises a new notification.

```ts
(notification: IOConnectNotificationOptions) => Promise<Notification>
```

**Parameters**

- **`notification`** (`IOConnectNotificationOptions`, required)
  Options for the raised notification.

**Returns**: `Promise<Notification>`

### setFilter

Sets a filter with apps allowed or not allowed to raise notifications.

```ts
(filter: NotificationFilter) => Promise<NotificationFilter>
```

**Parameters**

- **`filter`** (`NotificationFilter`, required)
  Filter with names of apps allowed or not allowed to raise notifications.

**Returns**: `Promise<NotificationFilter>`

### setState

Sets the state of a notification.

```ts
(id: string, state: State) => Promise<void>
```

**Parameters**

- **`id`** (`string`, required)
  ID of the notification to change.
- **`state`** (`State`, required)
  Value for the new notification state.

**Returns**: `Promise<void>`

### setStates

Sets multiple notifications to the same notification state.

*Since: io.Connect Desktop 9.5, @interopio/desktop 6.8.0*

```ts
(notifications: string[], state: IOConnectDesktop.Notifications.State) => Promise<void>
```

**Parameters**

- **`notifications`** (`string[]`, required)
  List of IDs of the notifications whose state to set.
- **`state`** (`IOConnectDesktop.Notifications.State`, required)
  Value for the new notification state.

**Returns**: `Promise<void>`

### snooze

Snoozes a notification.

*Since: io.Connect Desktop 9.3, @interopio/desktop 6.3.1*

```ts
(id: string, duration: number) => Promise<void>
```

**Parameters**

- **`id`** (`string`, required)
  ID of the notification to snooze.
- **`duration`** (`number`, required)
  Interval in milliseconds for which to snooze the notification.

**Returns**: `Promise<void>`

### snoozeMany

Snoozes multiple notifications for the same duration.

*Since: io.Connect Desktop 9.5, @interopio/desktop 6.8.0*

```ts
(notifications: string[], duration: number) => Promise<void>
```

**Parameters**

- **`notifications`** (`string[]`, required)
  List of IDs of the notifications to snooze.
- **`duration`** (`number`, required)
  Interval in milliseconds for which to snooze the notifications.

**Returns**: `Promise<void>`

### updateData

Sets or updates the arbitrary data associated with the notification which is available in the `data` property of the notification.

*Since: io.Connect Desktop 9.1, @interopio/desktop 6.1.0*

```ts
(id: string, data: unknown) => Promise<void>
```

**Parameters**

- **`id`** (`string`, required)
  ID of the notification whose data to update.
- **`data`** (`unknown`, required)
  New notification data.

**Returns**: `Promise<void>`

## Related types

- [ClickOptions](https://docs.interop.io/desktop/reference/javascript/notifications/clickoptions/index.md)
- [Configuration](https://docs.interop.io/desktop/reference/javascript/notifications/configuration/index.md)
- [IOConnectNotificationOptions](https://docs.interop.io/desktop/reference/javascript/notifications/ioconnectnotificationoptions/index.md)
- [Notification](https://docs.interop.io/desktop/reference/javascript/notifications/notification/index.md)
- [NotificationData](https://docs.interop.io/desktop/reference/javascript/notifications/notificationdata/index.md)
- [NotificationFilter](https://docs.interop.io/desktop/reference/javascript/notifications/notificationfilter/index.md)
- [NotificationPanelAPI](https://docs.interop.io/desktop/reference/javascript/notifications/notificationpanelapi/index.md)
- [State](https://docs.interop.io/desktop/reference/javascript/notifications/state/index.md)
- [UnsubscribeFunction](https://docs.interop.io/desktop/reference/javascript/search/unsubscribefunction/index.md)
