Notification Center
Backend SDK methods
Introduction
Architecture
Getting Started
- Sign Up on Novu Cloud
- Send First Notification
- Quickstarts
Subscribers
Activity Feed
Tenants
Notification Center
- Introduction to Notification Center
- UI Library Components
- Backend SDK methods
Content Creation & Design
Channels & Providers
- Overview
- Integration Store
- Novu Providers
- In-App
- Email
- SMS
- Push
- Chat
Security & Compliance
Community
Additional Resources
Notification Center
Backend SDK methods
Fetch subscriber’s In-App notifications feed
const { data: inAppMessages } = await novu.subscribers.getNotificationsFeed(
"subscriberId",
{
page: 0,
limit: 10,
// it is of type string. By default all feeds messages are fetched
feedIdentifier: "Product Updates",
// seen and read filter of type boolean
seen: true,
read: true,
}
);
Fetch all Messages Sent To All Subscribers
import { ChannelTypeEnum } from "@novu/node";
// All fields are optional
const listMessagesOptions = {
// pagination options
page: 0,
limit: 20,
/**
* Filter options
*/
// use ChannelTypeEnum.PUSH for push, ChannelTypeEnum.EMAIL for email,
channel: ChannelTypeEnum.IN_APP, // only In-App type messages will be fetched
subscriberId: "6444105141ffb0919496dfcb",
transactionIds: ["644-41051-41ffb0-919496-dfcb"],
};
const { data: messagesData } = await novu.messages.list(listMessagesOptions);
Delete an In-App notification/message
// messageId is of MongoDB Id type
await novu.messages.deleteById("messageId");
Mark an In-App Message as Read/Seen
const { data: markMessageAsRead } = await novu.subscribers.markMessageRead(
"subscriberId",
"messageId"
);
const { data: markMessageAsSeen } = await novu.subscribers.markMessageSeen(
"subscriberId",
"messageId"
);
Mark an In-App Message as Read/Unread/Seen/Unseen
const { data: markMessageAs } = await novu.subscribers.markMessageAs(
"subscriberId",
"messageId",
{ seen: true, read: false }
);
Mark all In-App Messages as Read/Unread/Seen/Unseen
import { MarkMessagesAsEnum } from "@novu/node"
const { data: markAllInAppMessages } = await novu.subscribers.markAllMessagesAs(
'subscriberId',
// can be filtered with feed identifiers
feedIdentifier: ['Marketing', 'Product']
// MarkMessageAsEnum.READ => It will mark all messages as read
// MarkMessageAsEnum.SEEN => It will mark all messages as seen
// MarkMessageAsEnum.UNREAD => It will mark all messages as unread
// MarkMessageAsEnum.UNSEEN => It will mark all messages as unseen
markAs: MarkMessageAsEnum.Read
);
Fetch All Feeds
const { data: feedsData } = await novu.feeds.get();
Was this page helpful?