Overview #
This method allows you to observe the count of unread notifications for the current user, including live updates.
React:
import { notification } from '@cord-sdk/react';
const counts = notification.useNotificationCounts({
filter: {
metadata: { flavor: 'minty' },
location: { page: 'bookmarks' },
groupID: 'group123',
},
});
return (
<div>
{!counts && "Loading..."}
{counts && (
<p>Unread notifications: {counts.unread}</p>
)}
</div>
);
Vanilla JavaScript:
const ref = window.CordSDK.notification.observeNotificationCounts(
(counts) => {
console.log("Unread notifications", counts.unread);
},
{ filter: {
metadata: { flavor: 'minty' },
location: { page: 'bookmarks' },
groupID: 'group123',
}}
);
import { notification } from '@cord-sdk/react';
const counts = notification.useNotificationCounts({
filter: {
metadata: { flavor: 'minty' },
location: { page: 'bookmarks' },
groupID: 'group123',
},
});
return (
<div>
{!counts && "Loading..."}
{counts && (
<p>Unread notifications: {counts.unread}</p>
)}
</div>
);
Copy
Available Data #
The API provides an object which has the following fields:
The number of notifications that the current user hasn't seen yet.
What this function returns #
A reference number which can be passed to unobserveSummary to stop observing notification summary information.
Arguments this function takes #
options #
optional
ObserveNotificationSummaryOptions
This is an object with the following fields: