Observe notification summary information

How to use the notification API to observe notification summary information


Overview

This method allows you to observe summary information about the current user's notifications, including live updates.

import { notification } from '@cord-sdk/react';
const summary = notification.useSummary();
Copy

Usage

import { notification } from '@cord-sdk/react';
const summary = notification.useSummary();
return (
  <div>
    {!summary && "Loading..."}
    {summary && (
      <p>Unread notifications: {summary.unread}</p>
    )}
  </div>
);
Copy

Available Data

Graphic showing example uses of the Cord Location Summary API

The API provides an object which has the following fields:


unread

number
The number of notifications that the current user hasn't seen yet.

What this function returns

The hook will initially return undefined while the data loads from our API. Once it has loaded, your component will re-render and the hook will return an object containing the fields described under "Available Data" above. The component will automatically re-render if any of the data changes, i.e., this data is always "live".


Arguments this function takes

This function takes no arguments.