createChannel static method
- GroupChannelCreateParams params,
- {ProgressHandler? progressHandler,
- Chat? chat}
Creates GroupChannel
with GroupChannelCreateParams.
#################### SECURITY TIPS #################### Before launching, you should review "Allow creating group channels from SDK" under ⚙️ Sendbird Dashboard -> Settings -> Security. It's turned on at first to simplify running samples and implementing your first code. Most apps will want to disable "Allow creating group channels from SDK" as that could cause unwanted operations. #################### SECURITY TIPS ####################
Implementation
static Future<GroupChannel> createChannel(
GroupChannelCreateParams params, {
ProgressHandler? progressHandler,
Chat? chat,
}) async {
sbLog.i(StackTrace.current, 'params.userIds: ${params.userIds}');
chat ??= SendbirdChat().chat;
final currentUserId = chat.chatContext.currentUserId ?? '';
if (params.userIds?.isEmpty ?? true) {
params.userIds = [currentUserId];
} else if (params.userIds?.contains(currentUserId) == false) {
params.userIds?.add(currentUserId);
}
return await chat.apiClient.send<GroupChannel>(GroupChannelCreateRequest(
chat,
params,
progressHandler: progressHandler,
));
}