[Problem/Question]
iOS createDistinctChannelIfNotExist method works wrong intermittently.
[SDK Version]
pod ‘SendbirdChatSDK’, ‘~> 4.19.0’
[Reproduction Steps]
func createChannelWithOneToOne(selectedUser: TotalUserModel) {
let createdTime = Date().getHourMinuteSecondsAndSSSS()
let orderCode = "ko_\(createdTime)"
let parameters = GroupChannelCreateParams()
parameters.addUserId(selectedUser.memberId)
parameters.name = orderCode
parameters.data = orderCode
parameters.customType = OrderStatus.START.rawValue
GroupChannel.createDistinctChannelIfNotExist(params: parameters) { channel, isCreated, error in
guard let channel else {
return
}
if isCreated {
// 1. When a new room is created with createDistinctChannelIfNotExist method this time
} else {
// 2. When a distinct room already exists with same person
// ask alert whether creating new room which is not distint
topViewController
.showDoubleButtonAlert(guideText: guideText,
leftButtonText: "common_yes".localized(),
rightButtonText: "channel_create_alert_enter_existing_channel".localized()) {
// 3. when user selects entering to exists room
} leftButtonAction: {
// 4. when user selects creating a new room
let newParameters = GroupChannelCreateParams()
newParameters.isDistinct = false
newParameters.addUserId(selectedUser.memberId)
newParameters.name = orderCode
newParameters.data = orderCode
newParameters.customType = OrderStatus.START.rawValue
GroupChannel.createChannel(params: newParameters) { newChannel, error in
print("DEBUG: createChannel inside" )
guard let newChannel else {
print("DEBUG: createChannel failed")
return
}
// enter a new room
}
}
}
}
}
[Frequency]
Usually when creating a group channel with someone very first time.
[Current impact]
Hello, we’re using SendbirdChat SDK, and when creating a new distinct group channel an error occurs.
In this process, our purpose is asking to users whether creating a new room or entering an existing room if it already exists.
So to find out weather a distinct room with the same user already exists, we’re using GroupChannel.createDistinctChannelIfNotExist method. That methods returns ‘isCreated’ parameter in the completionHandler, which indicates whether that room is created this time. So we understood if ‘isCreated’ parameter is false, a distinct channel already exists.
But the problem is, isCreated Method false even though they never had created any channel.
Seeing our source code, we expect to go where first annotation is on, but it goes where second annotation is on.
We tried to figure out which case is problematic, and we found out that usually first time, even when a new account tried to create channel with another new account who never talked with others.
But after the first time it seems to work well, even creating a new channel with someone first time.
So, we wanted to ask GroupChannel.createDistinctChannelIfNotExist method’s isCreated doesn’t have any bug or something. And if so, could you tell us if there is any other way to search a distinct channel exists when creating with a channel?