如何将第一条消息设置为接收者的未读?
我与两个参与者进行了对话:
var createdConversation = await ConversationResource.CreateAsync(uniqueName: uniqueName);
var sender = await ParticipantResource.CreateAsync(pathConversationSid: createdConversation.Sid, identity: "sender");
var receiver = await ParticipantResource.CreateAsync(pathConversationSid: createdConversation.Sid, identity: "receiver");
我想在此新创建的对话中发送一条初始消息:
var message = await MessageResource.CreateAsync(
pathConversationSid: createdConversation.Sid,
author: sender.Identity,
body: intitialMessage);
之后,我希望此新消息为读取
sender
接收者
似乎是不可能的。
我可以将sender
的lastreadMessageIndex
设置为创建message.index
,但这不会为reveriver < /代码>。只要
接收器
is null
unreadMessagesCount
也将是null
null < /code>,看起来
接收器
在此对话中没有新消息。
关于我如何与初始消息创建新对话的任何建议,这将显示为一位用户的未读?
I have a conversation with two participants:
var createdConversation = await ConversationResource.CreateAsync(uniqueName: uniqueName);
var sender = await ParticipantResource.CreateAsync(pathConversationSid: createdConversation.Sid, identity: "sender");
var receiver = await ParticipantResource.CreateAsync(pathConversationSid: createdConversation.Sid, identity: "receiver");
And I want to send a initial message in this newly created conversation:
var message = await MessageResource.CreateAsync(
pathConversationSid: createdConversation.Sid,
author: sender.Identity,
body: intitialMessage);
After that, I want this new message to be read
for the sender
and unread
for receiver
which seems not possible.
I can set the lastReadMessageIndex
of the sender
to the created message.Index
but this won't create read horizon for the receiver
. And as long as the lastReadMessageIndex
of the receiver
is null
, the unreadMessagesCount
will be also null
, and it will look like the receiver
has no new messages in this conversation.
Any suggestions on how I can create a new conversation with initial message, which will be displayed as unread for one of the users?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
目前不可能这样做。这是作为特征差距在内部在内部提出的。
同时,您可能需要解决问题。我想到的一件事是将任何具有
null
的lastreadMessageIndex
的对话标记为UI中未读的任何对话。Currently it is not possible to do this. This has been raised internally at Twilio as a feature gap.
In the meantime you may need to workaround it. One thing I thought of would be to mark any conversations that have a
lastReadMessageIndex
ofnull
as unread in your UI.由于没有“简单的方法”来实现这一目标,因此我正在加载对话及其消息来计算
unreadMessagesCount
。As there is no "easy way" to achieve this, I am loading the conversation and its messages to calculate the
unreadMessagesCount
.