EaseUI3.0 使用方式
快速集成
第 1步:集成 EaseUI前,首先需要集成环信 iOS SDK,参考:集成文档。
第 2 步:参考ChatDemo3.0导入的方式,直接将EaseUI拖入已经集成SDK的项目中
初始化
第 1步:引入相关头文件 #import “EaseUI.h”。
第 2 步:在工程的 AppDelegate中的以下方法中,调用 EaseUI对应方法。
[[EaseSDKHelper shareHelper] hyphenateApplication:application
didFinishLaunchingWithOptions:launchOptions
appkey:@"panadalove#yuwan20160719"
apnsCertName:@""
otherConfig:@{kSDKConfigEnableConsoleLogger:[NSNumbernumberWithBool:YES]}];
集成单聊,和聊天室
-(void)roomchat
{
EaseMessageViewController *chatController = [[EaseMessageViewControlleralloc]initWithConversationChatter:@"229351175885947308"conversationType:EMConversationTypeChatRoom];
chatController.title=@"testgroup1";
chatController.dataSource=self;
[self.navigationControllerpushViewController:chatControlleranimated:YES];
}
- (void)chat
{
EaseMessageViewController* emVC = [[EaseMessageViewControlleralloc]initWithConversationChatter:@"8004"conversationType:EMConversationTypeChat];
emVC.title = @"小坏蛋";
emVC.dataSource=self;
[self.navigationControllerpushViewController:emVCanimated:YES];
}
需要实现<EaseMessageViewControllerDataSource>协议
//实现协议,自定义用户头像和昵称
- (id<IMessageModel>)messageViewController:(EaseMessageViewController*)viewController
modelForMessage:(EMMessage*)message
{
id<IMessageModel> model =nil;
model = [[EaseMessageModelalloc]initWithMessage:message];
model.avatarImage = [UIImageimageNamed:@"EaseUIResource.bundle/user"];//默认头像
model.avatarURLPath = @"";//头像网络地址
model.nickname = @"昵称";//用户昵称
return model;
}
集成表情
在EaseMessageViewController.m文件的viewDidLoad结束前添加
EaseEmotionManager * manager = [[EaseEmotionManageralloc]initWithType:EMEmotionDefaultemotionRow:3emotionCol:7emotions:[EaseEmojiallEmoji]];
[self.faceViewsetEmotionManagers:@[manager]];
不需要集成实时语音通话和视频通话的项目中去除语音通话和视频通话的图标
删除EaseChatBarMoreView.m文件中
//语音通话和视频通话
// _audioCallButton =[UIButtonbuttonWithType:UIButtonTypeCustom];
// [_audioCallButtonsetFrame:CGRectMake(insets * 4 + CHAT_BUTTON_SIZE * 3, 10, CHAT_BUTTON_SIZE ,CHAT_BUTTON_SIZE)];
// [_audioCallButton setImage:[UIImageimageNamed:@"EaseUIResource.bundle/chatBar_colorMore_audioCall"]forState:UIControlStateNormal];
// [_audioCallButton setImage:[UIImageimageNamed:@"EaseUIResource.bundle/chatBar_colorMore_audioCallSelected"]forState:UIControlStateHighlighted];
// [_audioCallButton addTarget:selfaction:@selector(takeAudioCallAction) forControlEvents:UIControlEventTouchUpInside];
// _audioCallButton.tag =MOREVIEW_BUTTON_TAG + 3;
// [_scrollviewaddSubview:_audioCallButton];
//
// _videoCallButton =[UIButtonbuttonWithType:UIButtonTypeCustom];
// [_videoCallButtonsetFrame:CGRectMake(insets, 10 * 2 + CHAT_BUTTON_SIZE + 10, CHAT_BUTTON_SIZE ,CHAT_BUTTON_SIZE)];
// [_videoCallButton setImage:[UIImageimageNamed:@"EaseUIResource.bundle/chatBar_colorMore_videoCall"]forState:UIControlStateNormal];
// [_videoCallButton setImage:[UIImageimageNamed:@"EaseUIResource.bundle/chatBar_colorMore_videoCallSelected"]forState:UIControlStateHighlighted];
// [_videoCallButton addTarget:selfaction:@selector(takeVideoCallAction) forControlEvents:UIControlEventTouchUpInside];
// _videoCallButton.tag=MOREVIEW_BUTTON_TAG + 4;
// _maxIndex = 4;
// [_scrollview addSubview:_videoCallButton];