Using the SendBird JavaScript SDK, I am able to correctly create a private group for 1-to-1 messaging:
var params = new sb.GroupChannelParams();
params.isPublic = false;
params.isEphemeral = false;
params.isDistinct = true;
params.addUserIds([1, 2]);
params.operatorIds = [1];
params.name = name;
sb.GroupChannel.createChannel(params, function(groupChannel, error) {
if (error) {
console.log(error);
return false;
}
sb.GroupChannel.getChannel(groupChannel.url, function(groupChannel) {
var userIds = [2];
groupChannel.inviteWithUserIds(userIds, function(response, error) {
if (error) {
console.log(error);
return false;
}
console.log(response);
});
});
});
This all works correctly, and both users are able to see the private chatroom when retrieving the group list. However, when either user attempts to join the private group, an error is encountered:
SendBirdException: Not authorized. "Can't join to non-public channel.".
To join the group, I'm using the following code:
sb.GroupChannel.getChannel(id, function(openChannel, error) {
if (error) {
console.log(error);
return false;
}
console.log('Channel Found: ' + openChannel.name + '. Current Participants: ' + openChannel.participantCount);
openChannel.join(function(response, error) {
if (error) {
console.log(error);
return false;
}
console.log('Channel Joined: ' + openChannel.name + '. Current Participants: ' + openChannel.participantCount);
// retrieving previous messages.
});
});
The response from the above code is:
{
"message": "Not authorized. \"Can't join to non-public channel.\".",
"code": 400108,
"error": true
}
Any help is much appreciated. Note, I've checked the documentation and it does not mention how to join a private group (only a public one). I don't see how the "creator" of the chatroom is able to join the room, despite being set as the "operator".