Facebook Pixel

How do I let users control notification preferences?

Add a notificationPreferences object to the User model (messageEmail, messagePush, connectionEmail, dailyDigest, all booleans). Create a PATCH endpoint to update preferences. Check these flags before sending any notification.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Chat Notifications for Offline Users Email and Push Notifications

Maintain a Map of online users. When a message is sent, check if the receiver is online. If not, send an email notification with the sender's name, message preview, and a link to the chat. Rate-limit to 1 email per 10 minutes and respect user notification preferences.

Request Notification.permission on first visit. When a message is received via Socket.io and the tab is hidden (document.hidden), create a new Notification with the sender's name, message text, and icon. Handle notificationclick to open the chat URL.

Check NotificationLog for a recent notification (within 10 minutes) before sending. If one exists, skip. Also respect user preferences (notificationPreferences.messageEmail). Don't send to bounced or complained emails. Log each notification sent.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.