pb.inbox
Read, count, mark, and delete notifications for the signed-in user.
pb.inbox gives access to the signed-in user's notification inbox. Each method requires authentication. Read the Pagination guide if you are not familiar with paginated responses.
Methods overview
| Method | Description |
|---|---|
pb.inbox.fetch(options?) | Fetch paginated notifications |
pb.inbox.count() | Get the unread notification count |
pb.inbox.markRead(ids) | Mark one, several, or all notifications as read |
pb.inbox.delete(ids) | Delete notifications |
pb.inbox.fetch(options?): Fetch notifications
Sends GET /inbox/fetch. The result contains one page of notifications in data. For the next page, send the cursor from the previous response. Do not make a cursor.
// First page
const page = await ..({ : 20 })
const { , , } =
for (const of ) {
.(., ., .)
}
// Next page
if () {
const = await ..({ })
}Options:
| Option | Type | Default | Description |
|---|---|---|---|
limit | number | server default | Max notifications per page. |
cursor | string | Not set | Pagination cursor from previous response. |
unreadOnly | boolean | false | When true, only unread notifications are returned. |
Returns: Promise<Paginated<Notification>>
Unread-only feed
const { data } = await ..({ : true })
.(`${.} unread notifications`)Fetch all notifications
async function (): <Notification[]> {
const : Notification[] = []
let : string | undefined
let = true
do {
const page = await ..({ : 50, }) .(....)
= .
= .
} while ()
return
}pb.inbox.count(): Unread count
Fires GET /inbox/count. This works well for an unread badge because it returns only the count, without downloading the notification list.
const result = await ..()
.(`${.} unread notifications`)Returns: Promise<{ count: number }>
pb.inbox.markRead(ids): Mark as read
Fires POST /inbox/read. Pass an array of notification IDs for selected items or the exact string 'all' for the entire inbox.
// Mark specific notifications
const r1 = await ..(['id1', 'id2', 'id3'])
// Mark all notifications as read
const = await ..('all')Parameters:
| Value | Description |
|---|---|
string[] | Array of notification UUIDs to mark as read. |
'all' | Mark every notification as read at once. |
Returns: Promise<{ success: boolean; count: number }>
pb.inbox.delete(ids): Delete notifications
Fires POST /inbox/delete.
const result = await ..(['id1', 'id2'])
await ..('all')Pass an array to delete selected notifications. Pass 'all' to clear the inbox. Deletion is permanent. Make sure that the user confirms before the application sends 'all'.
Returns: Promise<{ success: boolean; count: number }>