Set DND by channel type
note
Use the callback to confirm the final result. On this page, the ErrorHandler callback succeeds when error?.isSuccess == true, while the OperationHandler callback succeeds when error == null.
Set the DND level for a channel type
Set the DND level for all channels of a specific type with BaseChannel.setChannelTypeNoDisturbLevel().
Method
Dart
static Future<int> setChannelTypeNoDisturbLevel(ChannelTypeNoDisturbLevelParams params, ErrorHandler handler)
ChannelTypeNoDisturbLevelParams
| Property | Type | Description |
|---|---|---|
channelType | ChannelType | Channel type (for example, ChannelType.direct or ChannelType.group) |
level | ChannelNoDisturbLevel | DND level: allMessage, none, mention, mentionUsers, mentionAll, blocked |
Code example
Dart
await BaseChannel.setChannelTypeNoDisturbLevel(
ChannelTypeNoDisturbLevelParams(
channelType: ChannelType.direct,
level: ChannelNoDisturbLevel.blocked,
),
(error) {
if (error?.isSuccess == true) {
print('Channel type DND set');
}
},
);
Get the DND level for a channel type
Query the current DND level for a channel type with BaseChannel.getChannelTypeNoDisturbLevel().
Method
Dart
static Future<int> getChannelTypeNoDisturbLevel(ChannelType channelType, OperationHandler<ChannelNoDisturbLevel> handler)
Parameters
| Parameter | Type | Description |
|---|---|---|
channelType | ChannelType | Channel type to query. |
handler | OperationHandler<ChannelNoDisturbLevel> | Callback that returns the current DND level or an error. |
Code example
Dart
await BaseChannel.getChannelTypeNoDisturbLevel(
ChannelType.direct,
(level, error) {
if (error == null) {
print('Current DND level: $level');
}
},
);