Mark notifications as read or unread

How to use the notification API to mark some or all notifications as read or unread


Mark A Specific Notification As Read #

Usage #

Vanilla JavaScript:
window.CordSDK.notification.markAsRead('my-awesome-notification-id');
window.CordSDK.notification.markAsRead('my-awesome-notification-id');
Copy

What this function returns #

A promise which resolves when the database write has completed.

Arguments this function takes #


notificationID #

required
string
The ID of the notification to mark as read.

Mark A Specific Notification As Unread #

Usage #

Vanilla JavaScript:
window.CordSDK.notification.markAsUnread('my-awesome-notification-id');
window.CordSDK.notification.markAsUnread('my-awesome-notification-id');
Copy

What this function returns #

A promise which resolves when the database write has completed.

Arguments this function takes #


notificationID #

required
string
The ID of the notification to mark as unread.

Mark All Notifications As Read #

Usage #

Vanilla JavaScript:
window.CordSDK.notification.markAllAsRead(
  { filter: { metadata: { flavor: 'minty' } } },
);
window.CordSDK.notification.markAllAsRead(
  { filter: { metadata: { flavor: 'minty' } } },
);
Copy

What this function returns #

A promise which resolves when the database writes have completed.

Arguments this function takes #


options #

optional
MarkAllNotificationsAsReadOptions
Miscellaneous options.

This is an object with the following fields:


filter
optional
NotificationListFilter
An object that can be used to filter the notifications marked as read.

This is an object with the following fields:


metadata
optional
EntityMetadata
An arbitrary JSON object specified when the notification is created. The value for a metadata entry should be an object representing the metadata key/value to filter on. For example, to show only notifications with the metadata key of "category" set to "sales", set the filter to { metadata: { category: "sales" } }.

location
optional
Location
The location where the notifications live. This will be the location of the thread containing the message which prompted the notification.

groupID
optional
string
The group to which the message that prompted the notification belongs.

Ask Cordy