Push notification preferences
By registering or unregistering the current user's registration token to the Sendbird server as below, you can turn push notifications on or off in the user's app. The registration and unregistration methods in the code below should be called after a user has established a connection with the Sendbird server via the connection methods such as connect(userId:completionHandler:)
or connect(userId:authToken:completionHandler:)
.
Through setPushTriggerOption
, the current user can set which message can trigger a push notification or completely turn it off as well. Besides, they can enable the Do Not Disturb (DND) and snooze features through setDoNotDisturb
and setSnoozePeriod
methods.
The setPushTriggerOption(_:completionHandler:)
setter allows users to configure the type of the message to trigger notifications for all group channels on the application level. The following three options are provided.
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. |
mentionOnly | 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. |
The setMyPushTriggerOption
setter also allows users to configure the type of the message to trigger notifications for each group channel. The following four options are provided.
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. |
mentionOnly | 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 on and off push notification on the current user's client app according to a specified schedule, use our Do Not Disturb
feature like the following.
Note:
Do Not Disturb
can also be set for a user with our Chat Platform API's update push preferences action.
Snooze
To snooze notifications for a specific period of time, use our snooze
feature like the following.
Note:
snooze
can also be set for a user with our Chat Platform API's update push preferences action.