Back

Inapp Inbox Notifications

Marking Notifications As 'Seen' Without Reading The In-App Inbox Notification Feed In Stream-JS

Sanjeev Kumar

February 7, 2025

•

February 7, 2025

•

Read summary :

Introduction:

In the realm of app development, swift and efficient notification handling is a key component of user engagement. This article explores a common challenge faced by developers using the stream-js library: marking a notification as "seen" without the need to read the entire notification feed.

Understanding the Challenge:

In scenarios where stream-js is employed, the task of marking a notification feed item as "seen" upon a user's interaction with a push notification is not straightforward. The hurdle lies in the fact that the addToMany calls, often used for efficiency, do not return the IDs of the added activities. On the contrary, the addActivity method provides the created activity, including the crucial activity ID.


    // Example of addActivity response
const response = {
  actor: 'ken',
  duration: '9.65ms',
  foreign_id: '',
  id: '8b5d69a9-8b73-11e8-98ab-12cb9e7b86a4',
  object: 'some-object',
  origin: null,
  target: '',
  time: '2018-07-19T16:48:21.045496',
  verb: 'add-activity'
};
Copied ✔

Identifying Added Activities:

To efficiently manage notifications, obtaining the activity ID is pivotal for subsequent actions.


    const activityId = response.id;
Copied ✔

Marking Notifications as Seen or Read:

Learn the process of marking a notification feed item as "seen" or "read" using the mark_seen or mark_read options.


    // Example: Marking all items as seen
const feed = client.feed('notification', 'user123');
feed.get({ mark_seen: true });

Copied ✔

Working with Activity Group IDs:

Understand the significance of activity group IDs when marking items as seen or read, focusing on the default aggregation format that utilizes the activity ID.

Efficient Solution:

Proposing a streamlined solution for marking a single activity as seen, leveraging the activity ID returned by the addActivity call.


// Example: Marking a specific activity group as seen
const feed = client.feed('notification', 'user123');
feed.get({ mark_seen: true, group: activityId });


Copied ✔

Handling addToMany and Efficiency Concerns:

Addressing concerns about using addToMany for populating many feeds and evaluating efficiency against practicality.

Explore InApp Inbox Before Use!

Conclusion:

In conclusion, this article provides a comprehensive guide for developers utilizing stream-js, offering insights into effectively managing notifications and overcoming the challenge of marking activities as "seen" without the need to read the entire feed. Developers are encouraged to choose the approach that best aligns with the specific needs of their application, ensuring a seamless and user-friendly notification experience.

Give your sales team an unfair advantage

Learn the basics of customer engagement and explore different ways to engage your ideal customer

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

On this page

Subscribe to

SuprSend product updates

Read the notification best practices, product updates, latest industry insights and more from our team.
Integrate complete notification engine in minutes. Free for your 10,000 monthly notifications. No credit card required
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Subscribe to

SuprSend product updates

Read the notification best practices, product updates, latest industry insights and more from our team.
Integrate complete notification engine in minutes. Free for your 10,000 monthly notifications. No credit card required
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.