N
Novu2w ago
Shri

novu.subscribers.getUnseenCount(<subscriber>, false) always returns 0

Hey folks, I found an issue where the novu.subscribers.getUnseenCount method always returns zero in the response when set to false even if there are unseen in-app notifications for the subscriber.
data: { data: { count: 0 } }
data: { data: { count: 0 } }
Alternatively running the same query with true shows the correct number of already read messages for the subscriber.
data: { data: { count: 89 } }
data: { data: { count: 89 } }
This bug is preventing me from setting the correct number of notifications in the badge for the app after triggering an in-app notification + a push notification with the unread count.
1 Reply
Shri
ShriOP2w ago
BTW I need to use this method instead of the React hook because I am calling this in my Remix Action method and I cannot use the react hook for counts. CC @Dima Grossman @Pawan Jain This feels very hacky and I wish there was an API that returned the unread count for a certain type of channel so I can use that to show the accurate badge count in my push notifications.
// Fetch the top 50 in_app messages for the subscriber and find the unread count
const messageList = await novu.messages.list({channel: ChannelTypeEnum.IN_APP, limit: 50 })

let unreadCount = 0
messageList.data.data.forEach(async (message) => {
if (message.read === false) {
unreadCount++
}
})
// Fetch the top 50 in_app messages for the subscriber and find the unread count
const messageList = await novu.messages.list({channel: ChannelTypeEnum.IN_APP, limit: 50 })

let unreadCount = 0
messageList.data.data.forEach(async (message) => {
if (message.read === false) {
unreadCount++
}
})
Want results from more Discord servers?
Add your server