有没有遇到过这样的问题,在最近聊天记录列表外面有 @ 你的音讯,点列表外面对应的记录,进入聊天页面当前,跳到了最新接管到的音讯,想要看 @ 本人的音讯,还得可劲儿的下来去找,应用体验不好,想要改善的话,往下看。
实现思路就是获取会话中 @ 本人的音讯,把这条音讯的工夫传给聊天页面,而后再跳转,就能够跳转到这条音讯了。
- 在 push 到会话页面之前,调 RCIMClient 类上面接口,获取 @ 本人的音讯
/*! 获取会话中@揭示本人的音讯 @param conversationType 会话类型 @param targetId 指标会话ID @discussion 此办法从本地获取被@揭示的音讯(最多返回10条信息) @warning 应用 IMKit 留神在进入会话页背后调用,否则在进入会话革除未读数的接口 clearMessagesUnreadStatus: targetId: 以及 设置音讯接管状态接口 setMessageReceivedStatus:receivedStatus:会同步革除被提示信息状态。 */- (NSArray *)getUnreadMentionedMessages:(RCConversationType)conversationType targetId:(NSString *)targetId;
- 遍历失去数组,找到本人想要跳转到的音讯,把音讯的 sentTime 传给要跳转的聊天页面,再 push 到聊天页面。
/** 进入页面时定位的音讯的发送工夫 @discussion 用于音讯搜寻之后点击进入页面等场景 */@property (nonatomic, assign) long long locatedMessageSentTime;
示例代码
- (void)onSelectedTableRow:(RCConversationModelType)conversationModelType conversationModel:(RCConversationModel *)model atIndexPath:(NSIndexPath *)indexPath { if (model.conversationType == ConversationType_GROUP) { NSArray *msgs = [[RCIMClient sharedRCIMClient] getUnreadMentionedMessages:model.conversationType targetId:model.targetId]; if (msgs.count > 0) { RCMessage *msg = msgs[0]; RCConversationViewController *vc = [[RCConversationViewController alloc] initWithConversationType:model.conversationType targetId:model.targetId]; vc.locatedMessageSentTime = msg.sentTime; [self.navigationController pushViewController:vc animated:YES]; } }}
代码接口文档:https://docs.rongcloud.cn/v4/...
融云的官网:https://www.rongcloud.cn/
从融云的官网文档可能找到点击会话列表 cell 的回调办法,在该办法里获取 @ 本人的音讯,如果有,将该音讯的 sentTime 设置给聊天页面对象的 locatedMessageSentTime,再 push。
**注:示例代码中应用的聊天页面是融云 SDK 中的原始类,如果你本人继承了,就替换为你本人的类,别的就没啥了。