N
Novuβ€’5mo ago
Luiz Carvalho

Novu Headless Socket

Hey everyone! πŸ‘‹ I'm using the Novu headless client and currently subscribing to:
novu.on("notifications.notification_received", (data) => {
console.log("new notification =>", data);
});

novu.on("notifications.unread_count_changed", (data) => {
console.log("new unread notifications count =>", data);
});
novu.on("notifications.notification_received", (data) => {
console.log("new notification =>", data);
});

novu.on("notifications.unread_count_changed", (data) => {
console.log("new unread notifications count =>", data);
});
However, I'd like to subscribe directly to the lower-level WebSocket event for notification_received. The reason is that the payload I send via the API includes some additional fields that don't seem to be exposed by the notifications.notification_received event. Is there a more elegant or recommended way to listen directly to the raw WebSocket payload, so I can access these extra fields? Or should I extend the client and manually handle the WebSocket connection myself? Thanks for any guidance! πŸ™
2 Replies
Pawan Jain
Pawan Jainβ€’5mo ago
@Luiz Carvalho You must be seeing data field in the notification response payload values can be mapped to data object keys. checkout this doc https://docs.novu.co/platform/inbox/react/components/inbox#data-object
Luiz Carvalho
Luiz CarvalhoOPβ€’5mo ago
Hi @Pawan Jain, I understand that it works, but I would like these parameters to come via API and not be linked to the template.

Did you find this page helpful?