This article details how to use the notification feed group to receive notifications for new activities and new reactions (likes, comments, etc.) as well as some basics on the aggregation formats you can customize in your dashboard.
When you create an application, you'll notice 'notification' in the default feed groups. This is the feed we will be working with.
New Post Notifications
For a user (User A) to receive notifications from another user's (User B) activities, you need User A's notification feed to follow User B's user feed. This will typically also occur at the same time User A's timeline feed follows User B. Here's an example:
const followSomeone = async () => {
await timelineFeed.follow('user', 'Sylwia')
await notificationFeed.follow('user', 'Sylwia')
}
By default, a follow relationship will return the most recent 100 activities of the followed feed when the feed is queried using .get(), but you may want to customize this to only allow new activities to be returned after a follow relationship is made. To do this, provide .follow() with a third options argument. It would look like this...
await notificationFeed.follow('user', 'Sylwia', {limit: 0})
Reaction Notifications
You can also use this feed group to get notified about new reactions. To implement this, take advantage of the targetFeeds field when adding a reaction. For example...
const like = await userFeed.client.reactions.add(
"like",
activity.id,
{
targetFeeds: [`notification:${activity.actor.id}`],
}
);
Related Articles:
Comments
0 comments
Please sign in to leave a comment.