【发布时间】:2020-03-20 10:12:40
【问题描述】:
使用 SendBird JavaScript SDK,我能够正确地为一对一消息创建一个私人组:
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);
});
});
});
这一切正常,在检索群组列表时,两个用户都可以看到私人聊天室。但是,当任一用户尝试加入私有组时,都会遇到错误:
SendBirdException:未授权。 “不能加入非公开 频道。”。
要加入群组,我使用以下代码:
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.
});
});
上述代码的响应是:
{
"message": "Not authorized. \"Can't join to non-public channel.\".",
"code": 400108,
"error": true
}
非常感谢任何帮助。请注意,我已经检查了文档,它没有提到如何加入私人群组(只有公共群组)。尽管被设置为“操作员”,但我看不到聊天室的“创建者”如何能够加入房间。
【问题讨论】:
标签: javascript sendbird