环信-即时通讯3.x

环信文档写的基本可以,但我在Pods时,却遇到问题,我Pod的是:


Pod

登录、注册、简单聊天都不再细说。主要说下好友列表+添加朋友+以及朋友收到的请求处理:

一、好友列表

我在Appdelegate中添加:

[[NSNotificationCenterdefaultCenter]postNotificationName:@"messCount"object:niluserInfo:@{@"allMes":aMessages}];

记得清除:[[NSNotificationCenterdefaultCenter]removeObserver:selfname:@"messCount"object:nil];

记得在ViewController上增加:

[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(badgeCount:)name:@"messCount"object:nil];

这里可以监听到信息,以及未读信息。当然在这个页面里也增加读取用户朋友列表。

二、登录、注册等

这一块官方文档写的比较完善,加载即可使用。

三、添加朋友

[[EMClient sharedClient].contactManager addContact:@“好友名字” message:@"我想加您为好友"];

当然,这里主要说下,被加人的监听方法,在appdelegate里写:

[[EMClient sharedClient].contactManager addDelegate:self delegateQueue:nil];

- (void)friendRequestDidReceiveFromUser:(NSString *)aUsername

message:(NSString *)aMessage;在这里即可进行

四、聊天

EaseMessageViewController *chatController = [[EaseMessageViewController alloc] initWithConversationChatter:@"***" conversationType:EMConversationTypeChat];

chatController.hidesBottomBarWhenPushed = YES;

[self.navigationController pushViewController:chatController animated:YES];

简单粗暴。写的不好,有什么问题可以直接留言细说。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容