# API

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

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

## Methods

### clear

Clears a specified notification.

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

**Parameters**

- **`id`** (`string`, required)
  The id of the notification to be removed.

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

### clearAll

Removes all known notifications from the system.

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

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

### clearOld

Clears all notifications that the user has already seen.

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

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

### click

Issues a programmatic click on a notification.

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

**Parameters**

- **`id`** (`string`, required)
  The id of the notification to click on.
- **`action`** (`string`, optional)

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

### configure

Configures the Global notification settings.

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

**Parameters**

- **`options`** (`Configuration`, required)
  configuration options

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

### 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>`

### getPermission

**io.Connect Browser** only. Retrieves the state of the native browser notification permission for the platform.

```ts
() => Promise<"default" | "granted" | "denied">
```

**Returns**: `Promise<"default" | "granted" | "denied">`

### list

Returns a list of all known notifications.

```ts
() => Promise<NotificationData[]>
```

**Returns**: `Promise<NotificationData[]>`

### onActiveCountChanged

Notifies when the number of active notification is changed.

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

**Parameters**

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

**Returns**: `UnsubscribeFunction`

### onClosed

Notifies the user when a notification was removed via the Notifications API.

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

**Parameters**

- **`callback`** (`(notification: { id: string }) => void`, required)
  A function which will be called when a notification is removed.

**Returns**: `UnsubscribeFunction`

### onConfigurationChanged

Notifies when the global notification settings are changed.

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

**Parameters**

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

**Returns**: `UnsubscribeFunction`

### onCounterChanged

Alias for `onActiveCountChanged()` for compatibility with **io.Connect Desktop**.

*Since: io.Connect Browser 4.0*

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

**Parameters**

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

**Returns**: `UnsubscribeFunction`

### onRaised

Notifies the user of any new raised notifications via the Notifications API.

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

**Parameters**

- **`callback`** (`(notification: NotificationData) => void`, required)
  A function which will be called when a new notification is raised.

**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: RaiseOptions) => Promise<Notification>
```

**Parameters**

- **`notification`** (`RaiseOptions`, required)
  notification options

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

### requestPermission

**io.Connect Browser** only. Triggers the native browser permission dialog. Must only be called from within a platform.

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

**Returns**: `Promise<boolean>`

### 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>`

## Related types

- [Configuration](https://docs.interop.io/browser/reference/javascript/notifications/configuration/index.md)
- [Notification](https://docs.interop.io/browser/reference/javascript/notifications/notification/index.md)
- [NotificationData](https://docs.interop.io/browser/reference/javascript/notifications/notificationdata/index.md)
- [NotificationFilter](https://docs.interop.io/browser/reference/javascript/notifications/notificationfilter/index.md)
- [RaiseOptions](https://docs.interop.io/browser/reference/javascript/notifications/raiseoptions/index.md)
- [State](https://docs.interop.io/browser/reference/javascript/notifications/state/index.md)
- [UnsubscribeFunction](https://docs.interop.io/browser/reference/javascript/search/unsubscribefunction/index.md)
