turtles
turtles
NNovu
Created by turtles on 5/9/2024 in #💬│support
Notification Center Configure Settings?
ahh exactly what I was after. Thanks
10 replies
NNovu
Created by turtles on 5/9/2024 in #💬│support
Notification Center Configure Settings?
Hey sorry was the weekend for me (New Zealand). Ahh yeah, had a look but that's to hide all preferences. I'm trying to show/hide specific preferences. Ideally I want the users account to meet a specific requirement before showing them the notification preferences for 'Job Complete' (see the screenshot from the original post). We have added a gross hack in the meantime to get the preference id from the button itself (the preference buttons have id="mantine-rh-control-PREFERENCE-ID-IS-HERE") and our backend sends us a list of allowed preferences and we filter them this way. So is there any prop or way to deal with individual preferences?
10 replies
NNovu
Created by turtles on 6/11/2023 in #💬│support
ITriggerOverrideFCM Overrides don't match Docs
We can see this payload in the messaging.onBackgroundMessage listener
{
"from": "1030072471020",
"messageId": "d1b3cd93-f03e-4e28-bc8b-3cdc3d990c42",
"notification": {
"title": "Infrastructure Flagged",
"body": " has been flagged as .",
"icon": "https://awebsite.com/images/PushIcon.png"
},
"data": {
"flag": "Requiring Maintenance",
"featureType": "Pump",
"linkAddress": "https://awebsite.com/link",
"label": "test label"
},
"fcmOptions": {
"link": "https://awebsite.com/link"
}
}
{
"from": "1030072471020",
"messageId": "d1b3cd93-f03e-4e28-bc8b-3cdc3d990c42",
"notification": {
"title": "Infrastructure Flagged",
"body": " has been flagged as .",
"icon": "https://awebsite.com/images/PushIcon.png"
},
"data": {
"flag": "Requiring Maintenance",
"featureType": "Pump",
"linkAddress": "https://awebsite.com/link",
"label": "test label"
},
"fcmOptions": {
"link": "https://awebsite.com/link"
}
}
The variables in notification part of the object above gets sent as normal push notification to our devices (which we don't want if we add the data object). If we had put those variables in the now omitted "payload" object then the template we specified on the Novu workflow would have filled them in for us. It seems like theres no way to send data messages via novu at the moment, or am I missing something key?
6 replies
NNovu
Created by turtles on 6/11/2023 in #💬│support
ITriggerOverrideFCM Overrides don't match Docs
Thanks there's some good stuff in there. I think the double notification trigger comes from us wanting a data message so we can handle it manually in the background. It seems like you can only send notification messages with Novu at the moment? From the firebase docs: https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
Use notification messages when you want the FCM SDK to handle displaying a notification automatically when your app is running in the background. Use data messages when you want to process the messages with your own client app code.
Use notification messages when you want the FCM SDK to handle displaying a notification automatically when your app is running in the background. Use data messages when you want to process the messages with your own client app code.
I thought the data override would send it as a data message so we can handle it in the background with a listener in the firebase-messaging-sw.js like this
messaging.onBackgroundMessage(function (payload) {
console.log("in background", payload);
const notificationTitle = payload.notification.title;
const notificationOptions = {
body: payload.notification.body,
icon: "/images/logo.png",
data: {
link: payload.data?.link,
},
};

self.registration.showNotification(notificationTitle, notificationOptions); <-- triggers a second notification
messaging.onBackgroundMessage(function (payload) {
console.log("in background", payload);
const notificationTitle = payload.notification.title;
const notificationOptions = {
body: payload.notification.body,
icon: "/images/logo.png",
data: {
link: payload.data?.link,
},
};

self.registration.showNotification(notificationTitle, notificationOptions); <-- triggers a second notification
however if I send a notification with an override object like this
"overrides": {
"fcm": {
"data": {
"label": "test label",
"flag": "Flag",
"featureType": "a feature",
"linkAddress": "https://awebsite.com/link"
},
"webPush": {
"fcmOptions": {
"link": "https://awebsite.com/link"
},
"notification": {
"icon": "https://awebsite.com/images/PushIcon.png"
}
}
}
"overrides": {
"fcm": {
"data": {
"label": "test label",
"flag": "Flag",
"featureType": "a feature",
"linkAddress": "https://awebsite.com/link"
},
"webPush": {
"fcmOptions": {
"link": "https://awebsite.com/link"
},
"notification": {
"icon": "https://awebsite.com/images/PushIcon.png"
}
}
}
6 replies
NNovu
Created by turtles on 1/11/2023 in #💬│support
React - Little bit confused about new INotificationCenterStyles we can pass in
Makes sense. Thanks guys
4 replies
NNovu
Created by dr.really on 12/6/2022 in #💬│support
Fetching notifications on socket event
I had a go at this for a quick prototype. I had to use an extra useEffect before I could get a toast notification popping up
const { socket } = useSocket();

const { notifications, fetching, markAsSeen, refetch } = useNotifications();

useEffect(() => {
if (!fetching) {
notifications.forEach((message) => {
if (!message.seen) {
console.log(message._id, "Not Seen")
// show toast/notification
markAsSeen(message._id).then(() => console.log("marked as seen"))
}
})
}
},[notifications, markAsSeen, fetching]);

useEffect(() => {
if (socket) {
socket.on('unseen_count_changed', (data) => {
if (!fetching) {
refetch().then(() => {
console.log('refetch complete')
})
}
});
}
return () => {
if (socket) {
socket.off('unseen_count_changed');
}
};
}, [socket, refetch, fetching]);
const { socket } = useSocket();

const { notifications, fetching, markAsSeen, refetch } = useNotifications();

useEffect(() => {
if (!fetching) {
notifications.forEach((message) => {
if (!message.seen) {
console.log(message._id, "Not Seen")
// show toast/notification
markAsSeen(message._id).then(() => console.log("marked as seen"))
}
})
}
},[notifications, markAsSeen, fetching]);

useEffect(() => {
if (socket) {
socket.on('unseen_count_changed', (data) => {
if (!fetching) {
refetch().then(() => {
console.log('refetch complete')
})
}
});
}
return () => {
if (socket) {
socket.off('unseen_count_changed');
}
};
}, [socket, refetch, fetching]);
8 replies
NNovu
Created by turtles on 11/24/2022 in #💬│support
Novu Socket info
6 replies
NNovu
Created by turtles on 11/24/2022 in #💬│support
Novu Socket info
bump
6 replies