iOS环信3.1·集成·功能的实现
SDK集成
1.准备工作:
·此处假设你已经申请过环信的开发者账号。
·此处假设你已经在Apple开发者中心配置好证书,并上传至环信。
·如果你不需要离线消息的推送功能,可以不必配置证书。
·从环信官网下载好的最新SDK,解压缩到一易找的地方。
2.将ios_IM_sdk_V3.1.5
文件夹中的HyphenateFullSDK
文件夹拷贝
到你的工程目录文件夹
下。
![](https://yqfile.alicdn.com/img_f14fb57401407c0bbbf6a26b5b070703.png)
3.打开Xcode,按下快捷键:Alt+Command+A,将HyphenateFullSDK
添加到工程目录里。
![](https://yqfile.alicdn.com/img_d89679b6759c39c66073ed9eb3883047.png)
4.将HyphenateFullSDK
目录下的include
中的EMSDK.h
中的代码注释掉一部分:
![](https://yqfile.alicdn.com/img_fe20524208ed8bff2b404ee35ac8752a.png)
5.将HyphenateFullSDK
目录下的include
中的EMSDKFull.h
中的代码注释掉一部分:
![](https://yqfile.alicdn.com/img_b76fa486166a4b6a58e882dc0dc29b7e.png)
6.点Build Phases
→ Link Binary With Libraries
,添加依赖库
SDK 包含实时语音依赖库有:
CoreMedia.framework
AudioToolbox.framework
AVFoundation.framework
MobileCoreServices.framework
ImageIO.framework
libc++.dylib
libz.dylib
libstdc++.6.0.9.dylib
libsqlite3.dylib
libiconv.dylib
**(如果使用的是 xcode7,后缀为 tbd。)**
![](https://yqfile.alicdn.com/img_e282b3d16093b9f87356fb680b5c5543.png)
7.将ios_IM_sdk_V3.1.5
文件夹中的EaseUI
文件夹拷贝
到你的工程目录文件夹
下。
![](https://yqfile.alicdn.com/img_936c74397d6608ab4e7cf1a15019d0d4.png)
8.打开Xcode,按下快捷键:Alt+Command+A,将EaseUI
添加到工程目录里。
![](https://yqfile.alicdn.com/img_423c2e544d586de82d89939ae42243d5.png)
9.在你的XXX.pch
头文件的首尾部分,加入两行代码:
![](https://yqfile.alicdn.com/img_963b2a82070e6b2367048bf030cea406.png)
//另,注意:必须引入这两个系统库。否则会报错。
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
错误是这样:
![](https://yqfile.alicdn.com/img_7a31d7fffbecec0620e069ee8b49bd76.png)
10.可能存在的Error
·需要解决
:
环信中有MJRefresh,若你的工程中也引入了MJRefresh,请自行删除你的或者环信EaseUI中的MJRefresh任一即可。
当然,前提是,保证你的MJRefresh是最新的
环信中有SDWebImage库,所以,如果你有用到SDWebImage库,请自行删除你引入的SDWebImage。
当然,你可以选择不删除。但是,要做一点简单的操作。
只需在XXX.pch中删除之前的引用#import "UIImage+WebCache",换成引用#import "UIImage+EMWebCache"
11.集成的结尾,说明部分:
经过上面一系列的修改以及添加库。此时,需要测试一下。
按下快捷键:Command+B,编译应该会无误通过。
功能实现
包含:位置发送、语音发送、图片发送、拍照发送、语音通讯、视频通讯
1.引入环信官方Demo中的:ChatViewController.h
、ChatViewController.m
注释掉ChatViewController.m
如下代码部分,解决Error
:
简单来讲,就是注释掉红色警告行的代码即可。
//#import "ChatGroupDetailViewController.h"
//#import "ChatroomDetailViewController.h"
//#import "UserProfileViewController.h"
//#import "UserProfileManager.h"
//#import "ContactListSelectViewController.h"
//#import "ChatDemoHelper.h"
//#import "EMChooseViewController.h"
//#import "ContactSelectionViewController.h"
//if (ext && ext[kHaveUnreadAtMessage] != nil)
// {
// NSMutableDictionary *newExt = [ext mutableCopy];
// [newExt removeObjectForKey:kHaveUnreadAtMessage];
// self.conversation.ext = newExt;
// }
//UserProfileViewController *userprofile = [[UserProfileViewController alloc] initWithUsername:messageModel.message.from];
//[self.navigationController pushViewController:userprofile animated:YES];
//ContactSelectionViewController *selectController = [[ContactSelectionViewController alloc] initWithContacts:members];
//selectController.mulChoice = NO;
//selectController.delegate = self;
//[self.navigationController pushViewController:selectController animated:YES];
//ContactSelectionViewController *selectController = [[ContactSelectionViewController alloc] initWithContacts:members];
//selectController.mulChoice = NO;
//selectController.delegate = self;
//[self.navigationController pushViewController:selectController animated:YES];
//UserProfileEntity *profileEntity = [[UserProfileManager sharedInstance] getUserProfileByUsername:model.nickname];
//if (profileEntity) {
// model.avatarURLPath = profileEntity.imageUrl;
// model.nickname = profileEntity.nickname;
//}
// [[ChatDemoHelper shareHelper] setChatVC:nil];
// ChatGroupDetailViewController *detailController = [[ChatGroupDetailViewController alloc] initWithGroupId:self.conversation.conversationId];
// [self.navigationController pushViewController:detailController animated:YES];
// ChatroomDetailViewController *detailController = [[ChatroomDetailViewController alloc] initWithChatroomId:self.conversation.conversationId];
// [self.navigationController pushViewController:detailController animated:YES];
// 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];
//- (BOOL)viewController:(EMChooseViewController *)viewController didFinishSelectedSources:(NSArray *)selectedSources
//{
// if ([selectedSources count]) {
// EaseAtTarget *target = [[EaseAtTarget alloc] init];
// target.userId = selectedSources.firstObject;
// UserProfileEntity *profileEntity = [[UserProfileManager sharedInstance] getUserProfileByUsername:target.userId];
// if (profileEntity) {
// target.nickname = profileEntity.nickname == nil ? profileEntity.username : profileEntity.nickname;
// }
// if (_selectedCallback) {
// _selectedCallback(target);
// }
// }
// else {
// if (_selectedCallback) {
// _selectedCallback(nil);
// }
// }
// return YES;
//}
//- (void)viewControllerDidSelectBack:(EMChooseViewController *)viewController
//{
// if (_selectedCallback) {
// _selectedCallback(nil);
// }
//}
2.引入环信官方Demo中的:
ChatDemoHelper.h
、ChatDemoHelper.m
、 CallViewController.h
、CallViewController.m
删除ChatDemoHelper.m中的
介于
-(void) initHelper {
#ifdef REDPACKET_AVALABLE[[RedPacketUserConfig sharedConfig] beginObserveMessage];
#endif[[EMClient sharedClient] addDelegate:self delegateQueue:nil];[[EMClient sharedClient].groupManager addDelegate:self delegateQueue:nil];[[EMClient sharedClient].contactManager addDelegate:self delegateQueue:nil];[[EMClient sharedClient].roomManager addDelegate:self delegateQueue:nil];[[EMClient sharedClient].chatManager addDelegate:self delegateQueue:nil];
#if DEMO_CALL == 1[[EMClient sharedClient].callManager addDelegate:self delegateQueue:nil];[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(makeCall:) name:KNOTIFICATION_CALL object:nil];
#endif
}
与
#pragma mark - EMCallManagerDelegate
之间的所有代码。
当然,还是会有报错。
下面的代码也要删除:
-(void)_clearHelper {self.mainVC = nil;self.conversationListVC = nil;self.chatVC = nil;self.contactViewVC = nil;[[EMClient sharedClient] logout:NO];
#if DEMO_CALL == 1[self hangupCallWithReason:EMCallEndReasonFailed];
#endif
}
当然,你这样点击音视频按钮,还是不能弹出通话界面。
所以,你需要在你的XXX.pch
头文件里加入这么一行代码即可。
#define DEMO_CALL 1
![](https://yqfile.alicdn.com/img_01af92a732b0865decdfe5b8405d6f51.png)
要若想能弹出通话界面,设置根控制器,必须是这样的。
也就是在ChatDemoHelper.h中必须将你的聊天界面的控制器声明,命名最好是mainVC
。这样会比较省事儿。
![](https://yqfile.alicdn.com/img_4b2ebb974e20f5c850f955b74a2d770b.png)
在AppDelegate.m,加入这样的一句代码:
//tabBarCtr为你的聊天界面的视图控制器。可以是Tabbar,或者别的。
[ChatDemoHelper shareHelper].mainVC = tabBarCtr;
CECNavigationViewController *callNav = nil;
CECChatRootController *tabBarCtr = [[CECChatRootController alloc] init];
[ChatDemoHelper shareHelper].mainVC = tabBarCtr;
callNav = [[CECNavigationViewController alloc] initWithRootViewController:tabBarCtr];
callNav.navigationBarHidden = YES;
self.window.rootViewController = callNav;
iOS环信3.1·集成·功能的实现相关推荐
- 环信 php后台集成,集成环信IM功能
之前在项目中做过环信IM,一直都没时间整理这些笔记很功能 ,如今偷得浮生半日,花时间把之前的代码看了下 独自乐乐,不如众乐乐,然后把这部分整理下,分享给大家. 1 首先 注册环信官网注册账号 环信官 ...
- 集成IOS 环信SDK
集成IOS SDK 在您阅读此文档时,我们假定您已经具备了基础的 iOS 应用开发经验,并能够理解相关基础概念. 下载SDK 通过Cocoapods下载地址 不包含实时语音版本SDK(EaseMobC ...
- 环信IM快速集成集成,实现客服功能(单聊)
第一:你需要登入环信官网注册一个即时云通讯帐号和一个移动客服帐号. 创建一个自己的应用,获取APPkey等信息. 环信官网:http://www.easemob.com/ 第二:下载最新环信SDK,解 ...
- 【2021环信IM快速集成指南】PC Web、Uni-App、小程序集成都在这里了
本文将直白且详细的描述一下如何集成环信web端的IM SDK,(小程序.Uni-app通用).这是一篇快速集成攻略,其中更多的是对于官网文档的一篇注释说明,相信很多的小伙伴在准备将环信的IM即时通讯能 ...
- 环信IM客户端集成(整理)
1. 环信IM功能介绍 1. 平台架构 2. 发送消息 1. 为开发者提供基于移动互联网的即时通讯能力,如单聊.群聊.发语音.发图片.发位置.实时音频.实时视频等. ...
- iOS: 环信的推送
原文:http://m.blog.csdn.net/article/details?id=38824551 1.先创建一个apns证书,链接如下 http://developer.easemob.co ...
- 基于环信实现在线聊天功能
由于最近接触到的项目需要用到聊天功能,关于聊天的SDK跟安卓同事统一,最终选择了环信.在官方下载好SDK,并研究了一波,最终实现自定义聊天功能. ###实现前准备 1.下载环信SDK,我使用的版本是V ...
- 即时通讯环信IM的集成使用
点击进入我的个人博客 第三方即时通讯服务,环信 IM云的集成使用,我这里主要以 web集成为主,如何把单聊模块集成到自己的项目进行的操作讲解,更多详细操作可以参考官网提供的开发文档 文章目录 环信IM ...
- 环信即时通讯集成过程
最近一直挺忙,使用了一些第三方的东西,也遇见了不少的问题,前面使用的一些还好,比如推送,分享这些第三方都比较容易集成,这次集成环信的即时通讯还是费了一些周折,刚弄完,赶紧记录一下. 一.前期需要注意的 ...
最新文章
- vue插槽样式_Vue为什么要有插槽
- php ado,常用的php ADODB使用方法集锦
- 卷积神经网络CNN入门【pytorch学习】
- 【Matlab】求解积分方程的数值解
- Cloud一分钟 | 谷歌退出美国防部云计算竞标;网络黑灰产业已近千亿,个人信息泄露是源头...
- 2021曲靖高考成绩查询时间,2021年曲靖高考成绩排名及成绩公布时间什么时候出来...
- java读取一个应用程序_Java IO – 在写入其他应用程序时读取一个大文件
- 【Spring第二篇】IOC:控制反转
- [原] 让网页中的对话框不显示以前输入的信息
- springMVC学习(10)-上传图片
- 范华专栏 | 挪威主权基金2018年报解读
- 通过网店管家抓取奇门淘系订单数据
- 异数OS 织梦师-Xnign(四)-- 挑战100倍速Nginx,脚踩F5硬件负载均衡
- 多元线性回归预测:餐馆营业额与多因素实战
- opencv+hough直线检测+fitline直线拟合
- n*m的格子中正方形个数和长方形个数
- 试用一片3-8译码器74LS138和其它必要的门电路设计一个一位全加器, 被加数为Ai, 加数为Bi, 低位来的进位为Ci-1, 本位和为Si, 本位对高位的进位为Ci
- 隐马尔可夫模型的三个基本问题(例子说明)
- 用计算机怎么做成绩表,利用Excel制作一个简单的学生成绩表.doc
- c++map自动排序特性