0

The SendBird .NET Docs mention how to create a channel with userIDs but how do we retrieve this channel?

Then the docs mention a way to retrieve a channel with a URL but they don't mention how to create a channel with a URL.

I'm a bit confused. What am I missing? Could you please let me know how to create and retrieve a channel using either userIDs or a channel URL?

Ayudh
  • 1,673
  • 1
  • 22
  • 55

1 Answers1

1

Try this:

public async void ConnectToChannel(FormsChat.Model.User user, List<string> users) {
    GroupChannel group = null;
    IsBusy = true;

    GroupChannel.CreateChannelWithUserIds(users, true, (GroupChannel groupChannel, SendBirdException e) => {
        if (e != null)
        {
            // Error.
            return;
        }
        group = groupChannel;
     });
     await Task.Delay(3000);
     IsBusy = false;
     await Navigation.PushAsync(new ChatPage(user, group));
}

Additionally, see this sample for Xamarin.Forms using SendBird

Wilson Vargas
  • 2,841
  • 1
  • 19
  • 28
  • Ahh I see, so we do group = groupChannel; and that gives us the group URL once the channel is created? – Ayudh Dec 13 '18 at 03:12
  • Oh I see what is happening here. Everytime we want to connect a user to a channel, we create the channel with CreateChannelWithUserIds with distinct = true. Thanks for your help! I'm using your plugin btw. Thanks for that as well. – Ayudh Dec 13 '18 at 03:18
  • Additionally, where and when would I register the channel handler ? – Ayudh Dec 13 '18 at 03:28
  • 1
    You can register the channel handler when init your Chat View. See this line in my sample on gihutb : [Init()](https://github.com/wilsonvargas/SendBird-Xamarin/blob/15c935b77b922194c1a833c1ce7d2f3a7305c001/Xamarin.Forms%20Sample/FormsChat/FormsChat/ViewModels/ChatViewModel.cs#L70) If this helps you then mark it as response pls. – Wilson Vargas Dec 13 '18 at 17:26
  • may I ask why you have put ch.OnMessageReceived in a timer? – Ayudh Dec 14 '18 at 04:17
  • would it be possible to direct message you? – Ayudh Dec 15 '18 at 10:45