环信集成 2---基于环信Demo3.0,实现单聊功能
这几天在做环信,所以把环信相关的东西拿过来,做个系统点的东西
注意:
- 这里Demo集成的是带有实时语音功能的(libEaseMobClientSDK.a)。
- 环信库是直接拖拽EaseMobSDK文件夹到项目内的,没有使用pod管理。
最终效果

添加环信SDK
- 下载环信SDK 2.2.1
链接地址1 - 添加EaseMobSDK到项目中,并添加依赖库。这里需要注意的地方:libEaseMobClientSDKLite.a不包含实时语音功能,libEaseMobClientSDK.a包含所有功能。必须要删掉一个,否则会报错。这里删除libEaseMobClientSDKLite.a。
- 添加依赖库。参见官方文档
23
- 新创建一个pch,并在Build Settings中添加配置。
在pch中,导入头文件。#ifndef PrefixHeader_pch
#define PrefixHeader_pch
#import "EaseMob.h"
#endif /* PrefixHeader_pch */4
添加环信EaseUI
- 导入EaseUI到项目中,并实现基础的登陆功能。
找到Demo3.0的EaseUI目录,然后将如下文件,拖拽到项目中。并在pch文件中引入EaseUI.h#ifndef PrefixHeader_pch
#define PrefixHeader_pch
#import "EaseMob.h"
#import "EaseUI.h"
#endif /* PrefixHeader_pch */56 - 在AppDelegate.m中注册环信的SDK和UI。
- 在StoryBoard中新增一个按钮,并给予登陆方法。然后在方法中实现登陆功能。当登陆成功后,发送通知。收到通知后,跳转到UI提供的EaseMessageViewController界面。
其中APPDelegate中文件内容
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//注册SDK
[[EaseMob sharedInstance] registerSDKWithAppKey:@"easemob-demo#chatdemoui" apnsCertName:nil];
//注册UI
[[EaseSDKHelper shareHelper] easemobApplication:application
didFinishLaunchingWithOptions:launchOptions
appkey:@"easemob-demo#chatdemoui"
apnsCertName:nil
otherConfig:@{kSDKConfigEnableConsoleLogger:[NSNumber numberWithBool:YES]}];
[[EaseMob sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
return YES;
}
ViewController中的内容
- (IBAction)login:(id)sender {
//用户名:zlanchun 密码:123456
//异步登陆账号
[[EaseMob sharedInstance].chatManager asyncLoginWithUsername:@"zlanchun" password:@"123456" completion:^(NSDictionary *loginInfo, EMError *error) {
if (loginInfo && !error) {
//发送自动登陆状态通知
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_LOGINCHANGE object:@YES];
} else {
NSLog(@"login error: %@",error);
}
} onQueue:nil];
}
- (void)jumpToChatVC {
//创建聊天室 对象:zlanchun1
EaseMessageViewController *chatController = [[EaseMessageViewController alloc] initWithConversationChatter:@"zlanchun1" conversationType:eConversationTypeChat];
[self.navigationController pushViewController:chatController animated:YES];
}
继承Demo3.0中的功能
- 首先导入Demo3.0中如下文件到项目中:
7
- 导入class里单聊功能ChatView到项目中
8
- 导入完成后的项目目录
9
- 添加头文件到PCH中。
#ifndef PrefixHeader_pch
#define PrefixHeader_pch
//头文件
#import "ChatDemoUIDefine.h"
#import "EMAlertView.h"
#import "TTGlobalUICommon.h"
#import "UIViewController+DismissKeyboard.h"
#import "NSString+Valid.h"
#import "EaseMob.h"
#import "EaseUI.h"
#endif /* PrefixHeader_pch */ 注释未引用的文件,删除重复引用的文件,添加第三方库Parse的依赖。
注释未引用的文件:在ViewController.m中应用头文件
#import "ChatViewController.h"
。然后在跳转方法中,注册跳转VC,跳转即可。
ViewController.m新增部分:
- (void)jumpToChatVC {
//创建聊天室 对象:zlanchun1
//EaseMessageViewController *chatController = [[EaseMessageViewController alloc] initWithConversationChatter:@"zlanchun1" conversationType:eConversationTypeChat];
//创建基于Demo3.0Class的chatroom
ChatViewController *chatController = [[ChatViewController alloc] initWithConversationChatter:@"zlanchun1" conversationType:eConversationTypeChat];
[self.navigationController pushViewController:chatController animated:YES];
}
ChatViewController.m中需要注释的地方
#import "ChatViewController.h"
//#import "ChatGroupDetailViewController.h"
//#import "ChatroomDetailViewController.h"
#import "CustomMessageCell.h"
//#import "UserProfileViewController.h"
//#import "UserProfileManager.h"
//#import "ContactListSelectViewController.h"
- (void)messageViewController:(EaseMessageViewController *)viewController
didSelectAvatarMessageModel:(id<IMessageModel>)messageModel
{
//UserProfileViewController *userprofile = [[UserProfileViewController alloc] initWithUsername:messageModel.nickname];
//[self.navigationController pushViewController:userprofile animated:YES];
}
- (id<IMessageModel>)messageViewController:(EaseMessageViewController *)viewController
modelForMessage:(EMMessage *)message
{
id<IMessageModel> model = nil;
model = [[EaseMessageModel alloc] initWithMessage:message];
model.avatarImage = [UIImage imageNamed:@"EaseUIResource.bundle/user"];
// UserProfileEntity *profileEntity = [[UserProfileManager sharedInstance] getUserProfileByUsername:model.nickname];
// if (profileEntity) {
// model.avatarURLPath = profileEntity.imageUrl;
// }
model.failImageName = @"imageDownloadFail";
return model;
}
- (void)showGroupDetailAction
{
[self.view endEditing:YES];
// if (self.conversation.conversationType == eConversationTypeGroupChat) {
// ChatGroupDetailViewController *detailController = [[ChatGroupDetailViewController alloc] initWithGroupId:self.conversation.chatter];
// [self.navigationController pushViewController:detailController animated:YES];
// }
// else if (self.conversation.conversationType == eConversationTypeChatRoom)
// {
// ChatroomDetailViewController *detailController = [[ChatroomDetailViewController alloc] initWithChatroomId:self.conversation.chatter];
// [self.navigationController pushViewController:detailController animated:YES];
// }
}
- (void)transpondMenuAction:(id)sender
{
// if (self.menuIndexPath && self.menuIndexPath.row > 0) {
// id<IMessageModel> model = [self.dataArray objectAtIndex:self.menuIndexPath.row];
// ContactListSelectViewController *listViewController = [[ContactListSelectViewController alloc] initWithNibName:nil bundle:nil];
// listViewController.messageModel = model;
// [listViewController tableViewDidTriggerHeaderRefresh];
// [self.navigationController pushViewController:listViewController animated:YES];
// }
self.menuIndexPath = nil;
}
UIImageView+HeadImage.文件中注释
/************************************************************
* * EaseMob CONFIDENTIAL
* __________________
* Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of EaseMob Technologies.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from EaseMob Technologies.
*/
#import "UIImageView+HeadImage.h"
//#import "UserProfileManager.h"
@implementation UIImageView (HeadImage)
- (void)imageWithUsername:(NSString *)username placeholderImage:(UIImage*)placeholderImage
{
if (placeholderImage == nil) {
placeholderImage = [UIImage imageNamed:@"chatListCellHead"];
}
// UserProfileEntity *profileEntity = [[UserProfileManager sharedInstance] getUserProfileByUsername:username];
// if (profileEntity) {
// [self sd_setImageWithURL:[NSURL URLWithString:profileEntity.imageUrl] placeholderImage:placeholderImage];
// } else {
// [self sd_setImageWithURL:nil placeholderImage:placeholderImage];
// }
[self sd_setImageWithURL:nil placeholderImage:placeholderImage];
}
@end
@implementation UILabel (Prase)
- (void)setTextWithUsername:(NSString *)username
{
// UserProfileEntity *profileEntity = [[UserProfileManager sharedInstance] getUserProfileByUsername:username];
// if (profileEntity) {
// if (profileEntity.nickname && profileEntity.nickname.length > 0) {
// [self setText:profileEntity.nickname];
// [self setNeedsLayout];
// } else {
// [self setText:username];
// }
// } else {
// [self setText:username];
// }
[self setText:username];
}
@end
添加parse依赖库:
- StoreKit.framework
- Bolts.framework
- Parse.framework
- Accounts.framework
- Social.framework。
其中Bolts.framework/Parse.framework在文件夹EaseClass/3rdparty/Parse下。1011
删除重用引用MBProgressHUD库

删除wav.mm文件。

删除VoiceConvert文件

错误集合
报错1:未添加Parse依赖库引起的
clang: error: linker command failed with exit code 1 (use -v to see invocation)
错误。16解决办法:添加parse的依赖库,一共有5个(环信小哥告诉我有4个,结果,添加完4个依赖后,9个错误变成4个了。咋办?还好有Google,查parse依赖关系,发现15年7月份依赖增加了一个。)
剩余的4个错误("_OBJC_CLASS_$_SKPayment"
):17看看国外小哥怎么说得(地址)。
18报错2:删除重复引用MBProgressHUD库
19
报错3:删除重复引用wav.mm文件
20报错4:删除VoiceConvert文件
21
Demo程序见:这里(百度云盘)
链接:http://www.jianshu.com/p/f53be9664f14
环信集成 2---基于环信Demo3.0,实现单聊功能的更多相关文章
- iOS:集成环信EaseMobSDK单聊功能
当然在集成环信之前需要一些准备操作: 1.首先注册环信开发者账号,直接进入环信官网注册即可:http://www.easemob.com 2.按照文档一步一步将需要的文件全部拖入工程中:http:// ...
- 【开源分享】2018CRM C# 源码(基于小黄豆CRMv2.0.925.3版本功能更新)
分享出来的初衷,我分享一下最近我在小黄豆CRM2.0版本(小黄豆CRM+v2.0.925.3)上加的功能,如果有类似需求的,可以把功能代码发你,节约你的开发时间.(这是在小黄豆开源免费CRM①群231 ...
- iOS 环信集成问题(连文档都不说明的坑。。)
首先,关于环信SDK的下载和一些依赖库的添加,在此我就不做详细介绍,(http://www.easemob.com/download/im)附上环信官网文档,可以看一下,上面都可以下载,也有相关配置介 ...
- iOS 环信集成项目应用
环信iOS端3.0版本集成记录--聊天界面篇 环信离线推送证书... 1,环信处在后台的时候,消息的接收与推送 离线发推送 配置属性 EMCallOptions *options = [[EMClie ...
- 基于环信的仿QQ即时通讯的简单实现
代码地址如下:http://www.demodashi.com/demo/11645.html 我的博客地址 之前一直想实现聊天的功能,但是感觉有点困难,今天看了环信的API,就利用下午的时间动手试了 ...
- mui初级入门教程(五)— 聊聊即时通讯(IM),基于环信 web im SDK
文章来源:小青年原创发布时间:2016-06-15关键词:mui,环信 web im,html5+,im,页面传值,缓存转载需标注本文原始地址: http://zhaomenghuan.github. ...
- 李洪强iOS开发之-环信02.2_环信官网下载环信 SDK
李洪强iOS开发之-环信02.2_环信官网下载环信 SDK 移动客服即时通讯云 iOS SDK 当前版本:V3.1.4 2016-07-08 [ 版本历史 ] | 开发指南 | 知识库 | Demo源 ...
- 【微框架】Maven +SpringBoot 集成 阿里大鱼 短信接口详解与Demo
Maven+springboot+阿里大于短信验证服务 纠结点:Maven库没有sdk,需要解决 Maven打包找不到相关类,需要解决 ps:最近好久没有写点东西了,项目太紧,今天来一篇 一.本文简介 ...
- 阿里云短信验证_基于阿里云OpenAPI实现
阿里云短信服务 背景简介: 短信验证以及短信通知,目前已经应用的非常广泛,最近因项目需要,需要将原来的短信接口换成阿里云的的短信服务,原项目集成的短信服务能够实现短信的发送以及短信的验证整个过程,简单 ...
随机推荐
- python中read() readline()以及readlines()用法
[转自:http://www.ibm.com/developerworks/cn/linux/sdk/python/python-5/index.html#N1004E] 我们谈到“文本处理”时,我们 ...
- Sublime 3156 LICENSE key
mac sublime3 3156 LICENSE 转自:http://blog.csdn.net/myboyliu2007/article/details/78748253 下载地址:https:/ ...
- ASP入门(十七)-ASP #include
通过使用 #include 指令,您可以在服务器执行 ASP 文件之前,把另一个 ASP 文件的内容插入到这个 ASP 文件中. 如何使用 #include 指令 这里有一个名为 mypage.asp ...
- 一家VC支持企业的发展轨迹——了解每次融资后股权和期权的变化,以及股份是如何被稀释的【转载】
来源:ReachVc 该文是 ReachVC 上一篇文章,是某个投资公司副总裁的独立博客,文章写得不错.如果你是一个不太了解融资的创业者,那么本文将对你很有用.通过武林外传同福客栈的例子,了解每次融资 ...
- asp.net 常用于客户端注册的机器信息
项目需要:根据客户端信息去获取用户登录信息 1.根据客户端信息,并查询数据库是否有匹配.如果没有则重新插入客户端信息: 2.根据客户端的设置提交用户登录信息,用户登录成功后,查询以前是否有过配置信息, ...
- 移动端H5的一些基本知识点总结
移动端H5的一些基本知识点总结 来到这家公司之后,和曾经的工作发生了非常大的转变.曾经我一直是做PC端页面的.来到如今这家公司之后,主要是做手机移动端的页面. 移动端的页面在我这个做习惯了PC端页面的 ...
- Python标准库笔记(3) — datetime模块
datetime模块提供了简单和复杂的方式用于操纵日期和时间的类.虽然支持日期和时间运算,但实现的重点是为了输出格式化和操作高效地提取属性. 1. 模块内容 内容 描述 常量 datetime.M ...
- oracle的参数文件:pfile和spfile
1.pfile和spfile Oracle中的参数文件是一个包含一系列参数以及参数对应值的操作系统文件.它们是在数据库实例启动时候加载的,决定了数据库的物理 结构.内存.数据库的限制及系统大量的默认值 ...
- AVERAGE和averageif函数
1.AVERAGE(Number1,Number2……) 其中: Number1,number2,...是要计算平均值的 1-30 个参数. 注意事项: average函数的参数可以是一个,也可以是多 ...
- python之模块py_compile用法(将py文件转换为pyc文件)
# -*- coding: cp936 -*- #python 27 #xiaodeng #python之模块py_compile用法(将py文件转换为pyc文件):二进制文件,是由py文件经过编译后 ...