Search code examples
iosswiftsendbird

Create One to One Chat in Sendbird IOS


I was trying to create a chat application using SendBirdSDK. But I couldn't find any methods in the documentation to start chat with a user. I downloaded the sample project and checked it, but it contains group channels and open channels only.

Is there any such methods to create 1 to 1 messages or should I need to create a groupchat with single user ID only?

Any help will be apreciated


Solution

  • According to the documentation,

    A Group Channel is a private chat. A user may join the chat only through an invitation by another user who is already a member of the chatroom. A Group Channel can consist of one to hundreds of members. Creating a channel with two members allows 1-to-1 messaging.

    So you just need to create a Group Channel with two User IDs in order it to be a 1-to-1 chat. Also, you should enable the Distinct property, because also according to the docs:

    Consequently, we recommend that you enable the Distinct property in 1-to-1 messaging channels in order to reuse the same channel when a user chooses to directly message a friend. If the property is disabled, the user will create a new channel even if they have had previous conversations with the friend, and therefore will not be able to see or access previously sent messages or data.

    Reference: https://docs.sendbird.com/ios#group_channel_3_creating_a_group_channel