Why can I only create 1 channel?

I am trying to create multiple 1:1 channels for private chat within my flutter app. I am creating a GroupChannel with two unique userIds and a unique channelUrl for each channel. The first time I create a channel it works fine and I can see it in my dashboard. Every subsequent attempt the code executes without error but no channel is created in my dashboard. When I delete the one channel that created successfully manually from my dashboard, I am able to create another channel but this is the only way I am able to create more than one channel in total from code. I receive no error and there is no information on why this is happening.

Flutter SDK, current version

Create a channel with the following code and the channel is created successfully and appears in dashboard. Then update the userId’s and channel url and execute the code again. It runs without error but no channel is created in dashboard.

this happens 100% of the time.

Critical impact. The service is obviously useless if this is as designed.

try {
      final params = sb.GroupChannelParams()
        ..userIds = ['user1', 'user2']
        ..isDistinct = true
        ..channelUrl = 'user1-user2-channel';

      final channel = await sb.GroupChannel.createChannel(params);
      return channel;
    } catch (e) {
      print('createChannel: ERROR: $e');
      rethrow;
    }

Hello @peter,

Welcome to the Sendbird Community.

If you want to create and continue to use a single group channel for a 1-to-1 chat, set the isDistinct property of the channel to true . If the isDistinct property is set to false , multiple 1-to-1 channels with their own chat history and data may be created for the same two users even if a channel already exists between them.

What you’re describing is expected behavior. If you set isDistinct to false, this will no longer occur.

Hi @Tyler, thanks for the quick response. I figured this out shortly after I posted my issue. The part that was/is confusing to me is perhaps in the wording…

If you want to create and continue to use a single group channel for a 1-to-1 chat, set the isDistinct property of the channel to true .

This is what I want to do however, I do not want this to happen:

If the isDistinct property is set to false , multiple 1-to-1 channels with their own chat history and data may be created for the same two users even if a channel already exists between them.

So, I want a 1:1 chat but I don’t want more than one channel for the same two users, which it seemed was possible or likely to happen if isDistinct isn’t true. I guess in order to achieve my goal I need to set isDistinct to false and use a unique channelUrl for every pair of users in order to avoid having multiple channels for the same pair of users, if that makes sense?

@peter,

I’m not sure I understand your problem. If you are creating channel, with the same two user_ids, and you’re passing isDistinct as true, the system will create a channel if no channel exists. If it does exists, it passes back the existing channel. This accurately describes the behavior you outlined in your original post.

In your original post, it sounds like you were expecting multiple channels thus you should set isDistinct to false. If you don’t want multiple channels for the same 1:1, continue to use isDistinct as true.

Hi @Tyler ,

The problem I mentioned in the original post was that I couldn’t create more than 1 channel for a single user. If I create a channel where the userIds = [‘user1’, ‘user2’] with isDistinct = true then try and create another channel where userIds = ['user1, ‘user3’] with isDistinct = true it does not create the channel. The only channel that is ever created is the first one.

I am trying to create multiple distinct channels for a specific user. Ex. user1 and user2, user1 and user3, user1 and user4 etc… but I can only ever create the first channel that I attempt. Subsequent channels are not created so long as isDistinct = true.

I think I just figured it out… All the users need to already be created in SendBird. I was trying to create channels for a single user with other users that were not already created within sendbird. Once I created a bunch of test users in the system I am now able to create distinct channels for each pair as I originally wanted. Thank you for all your help @Tyler I would have gone down the wrong path without it. :slight_smile: