环信UI3.0的集成方法
介绍一下把环信EaseUI集成到项目中的具体实现步骤。
图2.11.集成UI之前要把环信的SDK集成到项目中,环信SDK有详细介绍
2. 就是把EaseUI以及需要的资源拖到项目中,如图2.1所示
图3.13.新建一个pch文件,在pch文件中导入
#import"EMSDK.h"
#import"EaseUI.h"
运行时会提示HyphenateSDK找不到,解决方法就是进入EMSDK.h中,把提示找不到的文件注释就OK了,如图3.1所示
图4.14.在编译时可能还会报错,要是在报错的话,只需要在自己的pch文件的头部和尾部添加 #ifdef __OBJC__ 和#endif,如图4.1所示
5.这样的话就会编译成功,接下来在控制器中导入#import"EaseMessageViewController.h"头文件
/**该头文件没有环信的兔斯基表情**/
若想要表情,要导入 ChatViewController.h文件
6.接下来我们可以在一个按钮的点击事件中写如下代码:
EaseMessageViewController*chatVC = [[EaseMessageViewControlleralloc]initWithConversationChatter:@"chat2"conversationType:EMConversationTypeChat];
chatVC.title=@"chat2";
[self.navigationControllerpushViewController:chatVCanimated:YES];
/**chat2 是代表接收方的ID**/
7.当我们写完这些代码运行时可能会崩溃,如果崩溃的话,我们只需要把崩溃的代码改成:
NSArray *array = [[NSArray alloc]initWithObjects:[UIImage imageNamed:@"chat_sender_audio_playing_full"], [UIImage imageNamed:@"chat_sender_audio_playing_000"], [UIImage imageNamed:@"chat_sender_audio_playing_001"], [UIImage imageNamed:@"chat_sender_audio_playing_002"], [UIImage imageNamed:@"chat_sender_audio_playing_003"], nil];
[[EaseBaseMessageCell appearance] setSendMessageVoiceAnimationImages:array];
NSArray * array1 = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"chat_receiver_audio_playing_full"],[UIImage imageNamed:@"chat_receiver_audio_playing000"], [UIImage imageNamed:@"chat_receiver_audio_playing001"], [UIImage imageNamed:@"chat_receiver_audio_playing002"], [UIImage imageNamed:@"chat_receiver_audio_playing003"],nil];
[[EaseBaseMessageCell appearance] setRecvMessageVoiceAnimationImages:array1];
图7.18.再次运行,编译成功,会弹出集成好的UI界面,我们可以发消息如图7.1所示