Configure push notification preferences
Push notification preferences allow you to control when and how users receive push notifications from Sendbird Chat. You can configure trigger options, Do Not Disturb schedules, and snooze periods to customize the notification experience.
Register or unregister the current user's registration token with the Sendbird server to turn push notifications on or off in the user's app. Call these methods after the user connects to the Sendbird server using the SendbirdChat.connect() method.
Through PushTriggerOption, the current user can choose which type of messages will trigger push notifications, or disable all push notifications. You can also enable Do Not Disturb and snooze features using the setDoNotDisturb() and setSnoozePeriod() methods.
Push trigger options
The PushTriggerOption enum allows users to configure when to receive notification messages as well as what types of messages trigger notification messages on the application level. The following are the available options.
List of push trigger options
| Option | Description |
|---|---|
ALL | When disconnected from the Sendbird server, the current user receives notifications for all new messages including messages the user has been mentioned in. |
MENTION_ONLY | When disconnected from the Sendbird server, the current user only receives notifications for messages the user has been mentioned in. |
OFF | The current user doesn't receive any notifications. |
Channel-level push trigger options
The GroupChannel.PushTriggerOption enum also allows users to configure the trigger for notification messages as well as turn notifications on or off for each group channel. The following are the available options.
| Option | Description |
|---|---|
DEFAULT | The current user's push notification trigger settings are automatically applied to the channel. This is the default setting. |
ALL | When disconnected from the Sendbird server, the current user receives notifications for all new messages in the channel including messages the user has been mentioned in. |
MENTION_ONLY | When disconnected from the Sendbird server, the current user only receives notifications for messages in the channel the user has been mentioned in. |
OFF | The current user doesn't receive any notifications in the channel. |
Do Not Disturb
If you want to routinely turn off push notifications on the current user's app according to a specified schedule, use the Do Not Disturb feature.
When evaluating whether to suppress a notification, the server checks in the following priority order:
- Snooze: If snooze is active, notifications are paused regardless of other settings.
- Day-of-week DND schedules: If weekly DND schedules are configured, the server checks the current time against the configured windows.
- Legacy DND: If no weekly DND schedules exist, the legacy
setDoNotDisturb()settings are used.
Day-of-week DND schedules and legacy DND are mutually exclusive — setting weekly DND schedules automatically disables legacy DND.
Note: The
setDoNotDisturb()andgetDoNotDisturb()methods have been deprecated as of Chat SDK v4.35.0. UsesetWeeklyDoNotDisturb()andgetWeeklyDoNotDisturb()instead for more flexible scheduling options.Note: You can also configure Do Not Disturb for a user through the Platform API. To learn more, see Update push notification preferences.
Weekly Do Not Disturb
Weekly Do Not Disturb allows you to set different Do Not Disturb time windows for each day of the week. This replaces the single-window setDoNotDisturb() method with more flexible scheduling.
Note: When evaluating whether to suppress a notification, the server checks snooze first, then weekly DND schedules, then legacy DND. Setting weekly DND schedules automatically disables legacy DND.
Set weekly Do Not Disturb schedules
TimeWindow
| Property name | Type | Description |
|---|---|---|
startHour | int | Specifies the start hour in 24-hour format. Range: 0-23. |
startMin | int | Specifies the start minute. Range: 0-59. |
endHour | int | Specifies the end hour in 24-hour format. Range: 0-23. |
endMin | int | Specifies the end minute. Range: 0-59. |
Cross-midnight windows
A DndTimeWindow only accepts time ranges within a single day, where startHour:startMinute must be strictly before endHour:endMinute. To create a DND window that spans midnight, use the DndTimeWindow.overnight() factory method. This method splits the window into two separate day entries on the client side before sending them to the server.
Get weekly Do Not Disturb schedules
Retrieve the current weekly Do Not Disturb configuration for the user.
Clear weekly Do Not Disturb schedules
Remove all weekly Do Not Disturb schedules for the user.
Snooze
To snooze notification messages for a specific period of time, use the snooze feature.
Note: You can also configure snooze for a user through the Platform API. To learn more, see Update push notification preferences.