Help with Notification Tray – totalUnreadCount is always zero for post creation

Hi,
We’ve enabled the notification tray feature for our application and are currently integrating it.
Authentication is working as expected—we’re retrieving a valid access token for User A1 and using it to call the API:
GET https://beta.amity.services/notifications/v3
However, the response always shows totalPages: 0 and totalUnreadCount: 0.
Scenario:

  1. User A2 creates a post in a shared community.
  2. User A1 then logs in and fetches the notifications.
    Result: totalUnreadCount is still 0.
  3. But if User A1 creates a post and User A2 comments on it,
    Then totalUnreadCount becomes 1.
    This suggests only notifications related to interactions on the user’s own content are counted, not general activity in the community.

Question:
What is the best practice to configure the notification tray so that:
A user (e.g., A1) receives notifications when others create posts, comment, or react within the same community?
We want to ensure users are notified of all relevant activity in their communities—not just interactions tied to their own content.

Specs:
Using “@amityco/ts-sdk”: “^6.30.4”, in angular application.
Sample Code:

    async getToken2(server_key: string, api_key: string, userName: string, displayName: string) {
        const response = await fetch('https://apix.us.amity.co/api/v3/authentication/token?userId=' + userName, {
            method: 'GET',
            headers: {
                'x-server-key': server_key,
                accept: 'application/json'
            }
        });
        
        const data = await response.json();
        if(data) {
            this.getSession(
                userName,
                displayName,
                data,
                api_key
            );
        }
    }

    async getSession(userId, displayName, token, api_key) {
        const response = await fetch('https://apix.us.amity.co/api/v3/sessions', {
            method: 'POST',
            headers: {
                'x-api-key': api_key,
                accept: 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                userId: userId,
                deviceId: this.uuid,
                displayName: displayName, // optional
                authToken: token // only required if using secure mode
            })
        });
        
        const data = await response.json();
        if(data) {
            this.getNotificationCount(data.accessToken);
            this.getNotificationHistory(data.accessToken);
        }
    }

    async getNotificationCount(token) {
        const response = await fetch('https://beta.amity.services/notifications/v3', {
            method: 'GET',
            headers: {
            'Authorization': "Bearer " + token
            }
        });
        
        const data = await response.json();
        console.log(data);
    }

    async getNotificationHistory(token) {
        const startAfter = 1745256102357; // Mon Apr 21 2025 12:21:42 GMT-0500
        const url = `https://beta.amity.services/notifications/v3/history?startAfter=${encodeURIComponent(startAfter)}`;

        const response = await fetch(url, {
            method: 'GET',
            headers: {
                'Authorization': "Bearer " + token
            }
        });

        const data = await response.json();
        console.log(data);
    }

Thanks!

Hello @Sowmya , Thank you for providing the detailed explanation and sample code.

We’ve noted the behavior you’re experiencing and will pass this to our development team for further investigation. We’ll follow up with an update once we have more insights to share.

Appreciate your patience and thanks again for reaching out!

Just checking in to see if there have been any updates regarding the issue we discussed earlier. I’m happy to provide any additional information if needed.

1 Like

Hello @Sowmya , Thank you for checking in.

Our team is now able to reproduce the issue and is actively investigating to identify the root cause. I’ll make sure to keep you updated as soon as we have any findings.

Please feel free to share any further details that might assist in the investigation.

Hello @Sowmya , Regarding the issue you encountered, we would like to suggest using our new Notification Tray feature.
You can refer to the full documentation here:
:link: Notification tray | Social+ Docs

Please feel free to reach out if you have any further questions. We’re happy to help!

Hi Team, Is there any documentation or sample code available for using the notification tray feature with the @amityco/ts-sdk?
I’m having difficulty understanding how to pass in the community ID (or target ID) to retrieve notifications specific to a community. In particular, I’m unsure how to filter or scope the notification retrieval based on community context.
For example, how can I pass the target ID to notificationTray to connect to the server and retrieve notifications where the lastSeen timestamp is June 10, 2025, 9:00 AM?
Any guidance on how to properly scope or filter these calls would be appreciated.

Hello @Sowmya, Thank you for your question.

Currently, the notification tray documentation provides guidance on using the notification tray feature with the @amityco/ts-sdk. However, filtering notifications by community ID (target ID) is not natively supported as a direct filter parameter in the public SDK as of now.

Is there a payload to pass the user ID and timestamp for marking notifications as seen?

I’d like to understand how to mark notifications as seen for a specific user. For example, if I have two users — Sample1 and Sample2 — I want to mark notifications as seen only for Sample1.

What would be the appropriate payload for this use case?

Additionally, is there support for passing a timestamp when marking notifications as seen (e.g., to set a custom “last seen” time)?

And for get notification tray items is always returning empty array.

const getNotificationTrayItems = await notificationTray.getNotificationTrayItems(
            { limit: 20 }, // The number of items to retrieve
            ({ data: notificationTrayItems, loading, error}) => {
                // Callback function to trigger
                if (!loading && notificationTrayItems) {
                    console.log(notificationTrayItems);
                }

                if (error) {
                    // handle error
                }
            },
        );
1 Like

Hello @Sowmya , To mark notifications as seen for a specific user, just make sure that user (e.g., Sample1) is logged in—no need to pass the user ID in the payload. The API will mark notifications as seen for the currently authenticated user.

Use markTraySeen() to update the tray’s seen timestamp on the server when the user visits the Notification Tray screen.

See docs for details:

Custom timestamps aren’t supported; it uses the current server time.

If there is no need for user id, then for below code, its always returning an empty array.

Hello @Sowmya,
Could you please confirm if the notification tray feature is already enabled for your account?
If not, kindly submit a request here:

Thank you!