[PERS SDK - v2.3.26](/sdk-reference/readme) / [Exports](/sdk-reference/modules) / NotificationManager

# Class: NotificationManager

Notification Manager - Clean, high-level interface for the notification inbox (Flow 1)

Notifications are delivered through two independent channels — use both together:

- **REST inbox** (this manager): source of truth, full content, pagination, read/unread state
- **WS Relay `notification.pending`** (`onPending()`): real-time wake signal, no content —
always follow up with a REST fetch


Real-time delivery **shares the same WebSocket connection** as `sdk.walletEvents` — no
second socket is opened. Call `connectRealtime()` once (after auth) to bind the channel.

**`Example`**

```typescript
await sdk.notifications.connectRealtime();
const inbox = await sdk.notifications.list({ unreadOnly: true });
const { count } = await sdk.notifications.getUnreadCount();

sdk.notifications.onPending(async () => {
  // Signal is a hint — always re-fetch for actual content
  await sdk.notifications.list();
  await sdk.notifications.getUnreadCount();
});
```

**`Example`**

```typescript
await sdk.notifications.send({
  recipientType: 'user',
  recipientId: userId,
  title: 'New reward available!',
  body: "You've earned 100 points.",
  category: 'campaign',
  entityId: campaignId,
});
```

## Table of contents

### Constructors

- [constructor](/sdk-reference/classes/notificationmanager#constructor)


### Methods

- [getChannelId](/sdk-reference/classes/notificationmanager#getchannelid)
- [list](/sdk-reference/classes/notificationmanager#list)
- [getUnreadCount](/sdk-reference/classes/notificationmanager#getunreadcount)
- [markAsRead](/sdk-reference/classes/notificationmanager#markasread)
- [delete](/sdk-reference/classes/notificationmanager#delete)
- [send](/sdk-reference/classes/notificationmanager#send)
- [connectRealtime](/sdk-reference/classes/notificationmanager#connectrealtime)
- [getNotificationContext](/sdk-reference/classes/notificationmanager#getnotificationcontext)
- [onPending](/sdk-reference/classes/notificationmanager#onpending)


## Constructors

### constructor

• **new NotificationManager**(`apiClient`, `walletEvents`, `events?`): [`NotificationManager`](/sdk-reference/classes/notificationmanager)

#### Parameters

| Name | Type |
|  --- | --- |
| `apiClient` | [`PersApiClient`](/sdk-reference/classes/persapiclient) |
| `walletEvents` | [`WalletEventsManager`](/sdk-reference/classes/walleteventsmanager) |
| `events?` | [`PersEventEmitter`](/sdk-reference/classes/perseventemitter) |


#### Returns

[`NotificationManager`](/sdk-reference/classes/notificationmanager)

#### Defined in

[managers/notification-manager.ts:57](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/notification-manager.ts#L57)

## Methods

### getChannelId

▸ **getChannelId**(`forceRefresh?`): `Promise`<`null` | `string`>

Get the Besu channelId for the authenticated account (auto-provisioned on first call).
Cached in-memory; pass `forceRefresh` to bypass the cache (e.g. after re-auth).

#### Parameters

| Name | Type | Default value |
|  --- | --- | --- |
| `forceRefresh` | `boolean` | `false` |


#### Returns

`Promise`<`null` | `string`>

#### Defined in

[managers/notification-manager.ts:73](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/notification-manager.ts#L73)

### list

▸ **list**(`options?`): `Promise`<`PaginatedResponseDTO`<`NotificationDTO`>>

List the authenticated account's notification inbox (paginated).

#### Parameters

| Name | Type |
|  --- | --- |
| `options?` | [`NotificationQueryOptions`](/sdk-reference/interfaces/notificationqueryoptions) |


#### Returns

`Promise`<`PaginatedResponseDTO`<`NotificationDTO`>>

#### Defined in

[managers/notification-manager.ts:80](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/notification-manager.ts#L80)

### getUnreadCount

▸ **getUnreadCount**(): `Promise`<`NotificationUnreadCountDTO`>

Get unread notification count (for a badge).

#### Returns

`Promise`<`NotificationUnreadCountDTO`>

#### Defined in

[managers/notification-manager.ts:87](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/notification-manager.ts#L87)

### markAsRead

▸ **markAsRead**(`id`): `Promise`<`NotificationDTO`>

Mark a notification as read.

#### Parameters

| Name | Type |
|  --- | --- |
| `id` | `string` |


#### Returns

`Promise`<`NotificationDTO`>

#### Defined in

[managers/notification-manager.ts:94](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/notification-manager.ts#L94)

### delete

▸ **delete**(`id`): `Promise`<`void`>

Delete a notification.

#### Parameters

| Name | Type |
|  --- | --- |
| `id` | `string` |


#### Returns

`Promise`<`void`>

#### Defined in

[managers/notification-manager.ts:101](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/notification-manager.ts#L101)

### send

▸ **send**(`dto`): `Promise`<`NotificationDTO`>

Send a direct notification. BUSINESS accounts may only target `recipientType: 'user'`;
TENANT (admin) accounts may target `'user'` or `'business'`.

#### Parameters

| Name | Type |
|  --- | --- |
| `dto` | `SendNotificationDTO` |


#### Returns

`Promise`<`NotificationDTO`>

#### Defined in

[managers/notification-manager.ts:109](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/notification-manager.ts#L109)

### connectRealtime

▸ **connectRealtime**(): `Promise`<`void`>

Resolve this account's channelId and bind it on the shared wallet-events socket,
connecting first if needed. Call once after authentication.

#### Returns

`Promise`<`void`>

#### Defined in

[managers/notification-manager.ts:130](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/notification-manager.ts#L130)

### getNotificationContext

▸ **getNotificationContext**(): [`NotificationContext`](/sdk-reference/interfaces/notificationcontext)

Get the notification routing context (channelId + topicIds) resolved for the socket.

#### Returns

[`NotificationContext`](/sdk-reference/interfaces/notificationcontext)

#### Defined in

[managers/notification-manager.ts:141](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/notification-manager.ts#L141)

### onPending

▸ **onPending**(`handler`): `BlockchainEventUnsubscribe`

Subscribe to real-time notification wake signals (`notification.pending`).
The signal carries no content — always follow up with `list()` / `getUnreadCount()`.

#### Parameters

| Name | Type |
|  --- | --- |
| `handler` | [`NotificationPendingHandler`](/sdk-reference/modules#notificationpendinghandler) |


#### Returns

`BlockchainEventUnsubscribe`

#### Defined in

[managers/notification-manager.ts:149](https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/notification-manager.ts#L149)