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:
- User A2 creates a post in a shared community.
- User A1 then logs in and fetches the notifications.
Result:totalUnreadCount
is still0
. - But if User A1 creates a post and User A2 comments on it,
ThentotalUnreadCount
becomes1
.
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!