[Problem/Question]
1-to-1 Chat Issue — Always Creating New Group Channels Instead of Reusing Existing One-to-One Chat
Hello, I am facing an issue with creating a one-to-one chat in Sendbird.
I have one business user and multiple customer users.
Example:
-
Business ID:
businessOwner509 -
Customer IDs:
p1660,p2345
My requirement is:
Business + Customer should always have only one 1-to-1 chat channel
But my current code always creates a new GroupChannel, even when a channel already exists for the same two users.
Here is my code:
let businessId = self.business_chat_data.value(forKey: "chat_id") as? String ?? ""
let customerId = self.user_chat_data.value(forKey: "chat_id") as? String ?? ""
let params = GroupChannelCreateParams()
params.isDistinct = true
params.userIds = [businessId, customerId]
// params.channelUrl = "chat_\(businessId)_\(customerId)" // optional
GroupChannel.createChannel(params: params) { channel, error in
if let error = error {
print("Error:", error.localizedDescription)
return
}
self.openChat(channelURL: channel!.channelURL)
}
Even with isDistinct = true, a new channel is created every time.
What am I doing wrong?
How can I ensure that Sendbird reuses the existing 1-to-1 channel for the same two users instead of creating a new one?