<h3>说明:</h3>
集成的SDK版本 V3.2.1
版本时间2016-11-12
集成时间2016-11-21
<h3>前提:</h3>
观看视频,视频地址如下:
环信SDK集成:http://www.imgeek.org/video/40
环信EaseUI集成:http://www.imgeek.org/video/39
<h3>具体集成过程:</h3>
<h4>一: 添加依赖库</h4>
- CoreMedia.framework
- AudioToolbox.framework
- AVFoundation.framework
4.MobileCoreServices.framework - ImageIO.framework
- libc++.tbd
- libz.tbd
- libsqlite3.tbd
- libstdc++.6.0.9.tbd
- Foundation.framework
-
libiconv.tbd (Xcode7以上)
最终效果如图:
<h4>二:一些设置 </h4>
1.修改info.plist文件,适配iOS9以上系统,在info.plist中添加
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
2.修改info.plist文件,适配iOS10.0,在info.plist中添加
为了调用相册,地理位置,话筒,照相机,通讯录
<key>NSPhotoLibraryUsageDescription</key>
<string>中华人需要使用相册服务获取照片</string>
<key>NSCameraUsageDescription</key>
<string>中华人需要使用照相机服务进行拍照获取照片</string>
<key>NSContactsUsageDescription</key>
<string>中华人需要使用通讯录服务进行好友邀请</string>
<key>NSMicrophoneUsageDescription</key>
<string>中华人需要使用话筒进行吐槽反馈信息</string>
<key>NSLocationUsageDescription</key>
<string>中华人需要使用定位服务来发送位置信息</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>中华人需要使用定位服务来发送位置信息</string>
3.Bulid Setting 设置bitcode 为NO,如图:
4.新建pch文件,如图:
进行设置,如图:
<h4>三:Appdelegate</h4>
#import "AppDelegate.h"
#import "ChatViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// SDK的初始化
/**
* EMOptions类是SDK的配置信息
* 可以加入推送证书的名称
*/
EMOptions *options = [EMOptions optionsWithAppkey:@"luoxiaoyong#mingxin"];
options.apnsCertName = @"Push_dev";
// 初始化SDK
EMError *error = [[EMClient sharedClient] initializeSDKWithOptions:options];
if (!error) {
NSLog(@"初始化成功");
}
// 登录
error = [[EMClient sharedClient] loginWithUsername:@"xrdaly001" password:@"123456"];
if (!error) {
NSLog(@"登录成功");
}
else {
NSLog(@"登录失败");
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
ChatViewController *vc = [[ChatViewController alloc] initWithConversationChatter:@"xrdaly002" conversationType:EMConversationTypeChat];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
<h4>四:添加键盘表情(说明)</h4>
在EaseMessageViewController.m的viewDidLoad方法结尾处加上
EaseEmotionManager * manager = [[EaseEmotionManager alloc] initWithType:EMEmotionDefault emotionRow:3 emotionCol:7 emotions:[EaseEmoji allEmoji]];
[self.faceView setEmotionManagers:@[manager]];
<h4>五:国际化文件乱码问题</h4>
下载demo,直接把demo中的国际化文件拷贝到现在项目中,ok
以上就是实现环信单聊的全部过程,,如有任何疑问欢迎加Q:714700382,我们共同讨论,共同进步