React & React NativeHooksApp NotificationsuseFetchAppNotifications

useFetchAppNotifications

Overview

The useFetchAppNotifications hook is used to retrieve a paginated list of app notifications for the currently authenticated user. Notifications include updates or actions relevant to the user within the project.

Usage Example

import { useFetchAppNotifications } from "@replyke/react-js";
 
function NotificationsList() {
  const fetchAppNotifications = useFetchAppNotifications();
 
  const handleFetchNotifications = async () => {
    try {
      const notifications = await fetchAppNotifications({ page: 1, limit: 10 });
      console.log("Fetched notifications:", notifications);
    } catch (error) {
      console.error("Failed to fetch notifications:", error.message);
    }
  };
 
  return <button onClick={handleFetchNotifications}>Fetch Notifications</button>;
}

Parameters & Returns

Parameters

The hook returns a function that accepts an object with the following fields:

ParameterTypeRequiredDescription
pagenumberYesThe page number to fetch.
limitnumberYesThe number of notifications per page.

Returns

The function resolves with an array of app notifications:

Return ValueTypeDescription
UnifiedAppNotification[]UnifiedAppNotification[]A list of app notifications for the user.