基于 融云demo研究 https://github.com/sealtalk/sealtalk-ios
集成 @ 功能
@ 消息推送会越过所有免打扰逻辑,给用户推送 Push 通知
[RCIM sharedRCIM].enableMessageMentioned = YES;
[RCIM sharedRCIM].groupMemberDataSource = RCDDataSource;
-(void)getAllMembersOfGroup:(NSString *)groupId result:(void (^)(NSArray<NSString *> *))resultBlock{
//To do --- 请求自己服务器接口获取
for (RCUserInfo *user in result) {
[ret addObject:user.userId];
}
resultBlock(ret);
}
群公告功能
查找聊天历史记录
需要2个参数传给搜索控制器:conversationType、targetId
在 searchBar textDidChange:代理调用
[[RCIMClient sharedRCIMClient] searchMessages:self.conversationType
targetId:self.targetId keyword:searchText count:50 startTime:0];
缺点:目前无法滚动到指定消息cell
https://developer.rongcloud.cn/ticket/info/B/AhyySD3xrNqZ5aOA==?type=1
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
self.resultArray = nil;
NSArray *array = [[RCIMClient sharedRCIMClient] searchMessages:self.conversationType targetId:self.targetId keyword:searchText count:50 startTime:0];
NSMutableArray *resultArray = [NSMutableArray array];
for (RCMessage *message in array) {
RCDSearchResultModel *messegeModel = [[RCDSearchResultModel alloc] init];
messegeModel.conversationType = self.conversationType;
messegeModel.targetId = self.targetId;
messegeModel.otherInformation = [RCKitUtility formatMessage:message.content];
messegeModel.time = message.sentTime;
messegeModel.searchType = RCDSearchChatHistory;
if (self.conversationType == ConversationType_GROUP) {
RCUserInfo *user = [[RCDataBaseManager shareInstance] getUserByUserId:message.senderUserId];
messegeModel.name = user.name;
messegeModel.portraitUri = user.portraitUri;
}else if(self.conversationType == ConversationType_PRIVATE){
RCUserInfo *user = [[RCDataBaseManager shareInstance] getUserByUserId:self.targetId];
messegeModel.name = user.name;
messegeModel.portraitUri = user.portraitUri;
}
[resultArray addObject:messegeModel];
}
self.resultArray = resultArray;
[self refreshSearchView:searchText];
if (self.resultArray.count < 50) {
self.isLoading = NO;
}else{
self.isLoading = YES;
}
}
------
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
RCDSearchResultModel *model = self.resultArray[indexPath.row];
RCDChatViewController *_conversationVC =
[[RCDChatViewController alloc] init];
_conversationVC.conversationType = model.conversationType;
_conversationVC.targetId = model.targetId;
_conversationVC.userName = model.name;
int unreadCount = [[RCIMClient sharedRCIMClient] getUnreadCount:model.conversationType targetId:model.targetId];
_conversationVC.unReadMessage = unreadCount;
_conversationVC.enableNewComingMessageIcon = YES; //开启消息提醒
_conversationVC.enableUnreadMessageIcon = YES;
//如果是单聊,不显示发送方昵称
if (model.conversationType == ConversationType_PRIVATE) {
_conversationVC.displayUserNameInCell = NO;
}
[self.navigationController pushViewController:_conversationVC
animated:YES];
}
集成讯飞语音输入
-
将SDK拖到项目里面
图片.png
一、
融云的讯飞输入法插件依赖于IMKit,把讯飞语音输入 SDK 文件夹拷贝到项目文件夹下,并导入到项目工程中。注:RongiFlykit依赖于讯飞的iflyMSC.framework和资源包RongCloudiFly.bundle
二、
Build Settings 中 Other Linker Flags 添加 -ObjC 。
三、
添加系统依赖库
除了IMKit所需的依赖库,还需要添加
Foundation.framework
AddressBook.framework
四、
如果需要修改讯飞sdk的appkey,来做一些业务统计,请在IMKit初始化之后调用下面的方法,保证IMKit加载该模块的时候,使用正确的讯飞appkey
注意!!!:因为讯飞的appkey和sdk是绑定的,所以如果你需要更换讯飞的appkey,就必须更换成对应的iflyMSC.framework
[RCiFlyKit setiFlyAppKey:@"58243521"];
如果需要更换自己的讯飞SDK,需要而外添加Contacts.framwork
讯飞SDK下载
网友评论