在 Sendbird 中创建一对一聊天 IOS

Create One to One Chat in Sendbird IOS

我正在尝试使用 SendBirdSDK 创建一个聊天应用程序。但是我在文档中找不到任何方法来开始与用户聊天。我下载了示例项目并检查了它,但它只包含组频道和开放频道。

是否有任何此类方法可以创建一对一消息,或者我是否需要创建一个仅具有单个用户 ID 的 groupchat

我们将不胜感激

我不确定,但在群组频道中,他们提供一对一的消息传递。但是为此你需要用其他 userID

创建一个组

您可以使用此处的参考代码:

https://sendbird.gitbooks.io/how-to-build-an-ios-messaging-app/content/en/implement_1-on-1_messaging.html

根据文档,

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.

所以您只需要创建一个有两个用户 ID 的群组频道,就可以进行一对一的聊天。此外,您应该启用 Distinct 属性,因为也根据文档:

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.

参考:https://docs.sendbird.com/ios#group_channel_3_creating_a_group_channel