集成视频
http://www.imgeek.org/video/42
EasyUI视屏
http://www.imgeek.org/video/41
官方文档
http://docs.easemob.com/im/300iosclientintegration/140iosquickstart
集成环信,首先第一步,
非cocoapod党的,下载SDKhttp://www.easemob.com/download/im
然后,导入SDK,直接拖HyphenateFullSDK或者HyphenateSDK其中一个进项目,然后导入依赖库
如果使用Lite版本SDK,并用拖动的方式添加EaseUI, 需要在
Build Settings
>
GCC_PREPROCESSOR_DEFINITIONS
中添加
ENABLE_LITE=1
(等号左右不能有空格)
大概就这些。
第三步,将bitcode 设为NO
然后就可以开始了。
申请账号,之类的就不提了。
在
AppDelegate中运行这些方法看看,能否运行。
//初始化对象,用AppKey
let options = EMOptions.init(appkey: "514774176#lulu")
options?.apnsCertName = "test_dev"
//初始化,如果出错就输出error
var error = EMClient.shared().initializeSDK(with: options)
if error == nil{
print("初始化成功")
}
//注册新用户,一般来说不由客户端做
// error = EMClient.shared().register(withUsername: "01273", password: "123")
// if error == nil{
// print("注册成功")
// }else{
// print("注册失败")
// }
//登录
error = EMClient.shared().login(withUsername: "111", password: "111")
if error == nil{
print("登录成功")
}else{
print("登录失败")
}
然后就开始弄界面了,
将EaseUI这个文件拉进项目
然后将文件里面的resources里面的info.plist文件删掉,不然上架的时候,会因为这个info.plist。上不了架。
桥接文件中导入
#import "EasyUI.h"
在easyUI文件夹里面有一个叫EaseUI-Prefix.pch文件,将文件写到build setting 里面的prefix header里面(拖过去)。
创建一个继承
EaseMessageViewController的类
在类里面添加这些方法
override init!(conversationChatter:String!, conversationType: EMConversationType) {
super.init(conversationChatter: conversationChatter, conversationType: conversationType)
}
override init(nibName nibNameOrNil:String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName:nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("fuck you")
}
在APPdelegate中这样跳转过去
id填写的是你想聊得对方账号
window?.rootViewController = DDChatViewController.init(conversationId:"123", conversationType: EMConversationTypeChat)