打开终端输入cd+空格拖进新建的工程.
然后输入pod init ,打开新建工程的文件夹, 里面就会有Podfile
文件,打开将下面的粘贴里面,输入pod install下载完成关闭
pod ‘RongCloudIM/IMLib’, ‘~> 2.8.3’
pod ‘RongCloudIM/IMKit’, ‘~> 2.8.3’
然后导入头文件在appdelegate
#import <RongIMKit/RongIMKit.h>
然后导入appdelegate
宏定义如下:
#define AppKey @“uwd1c0sxup9b1”
#define AppSecret @“kqruPcn6FmmGz”
#define UserToken @“Tw4JQH/UpgrHHLE0EgVWgOe3WRB5BB8a8vBhAxmNbpQaZKpzk/3Qa52vM5kVavwxuOSXHuAhYMu/TRZPMRoYqw==”
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[RCIM sharedRCIM] initWithAppKey:@“YourTestAppKey”];
[[RCIM sharedRCIM] connectWithToken:@“YourTestUserToken” success:^(NSString *userId) {
NSLog(@“登陆成功。当前登录的用户ID:%@”, userId);
} error:^(RCConnectErrorCode status) {
NSLog(@“登陆的错误码为:%d”, status);
} tokenIncorrect:^{
//token过期或者不正确。
//如果设置了token有效期并且token过期,请重新请求您的服务器获取新的token
//如果没有设置token有效期却提示token错误,请检查您客户端和服务器的appkey是否匹配,还有检查您获取token的流程。
NSLog(@“token错误”);
}];
return YES;
}
COM+N创建文件继承与RCConversationListViewController
(void)viewDidLoad {
//重写显示相关的接口,必须先调用super,否则会屏蔽SDK默认的处理
[super viewDidLoad];
//设置需要显示哪些类型的会话[self setDisplayConversationTypes:@[@(ConversationType_PRIVATE),@(ConversationType_DISCUSSION),@(ConversationType_CHATROOM),@(ConversationType_GROUP),@(ConversationType_APPSERVICE),@(ConversationType_SYSTEM)]];//设置需要将哪些类型的会话在会话列表中聚合显示[self setCollectionConversationType:@[@(ConversationType_DISCUSSION),@(ConversationType_GROUP)]];
}
- (void)onSelectedTableRow:(RCConversationModelType)conversationModelType
conversationModel:(RCConversationModel *)model
atIndexPath:(NSIndexPath *)indexPath {
RCConversationViewController *conversationVC = [[RCConversationViewController alloc]init];
conversationVC.conversationType = model.conversationType;
conversationVC.targetId = model.targetId;
conversationVC.title = @“想显示的会话标题”;
[self.navigationController pushViewController:conversationVC animated:YES];
}
进入AppDelegate.m中
- 导入创建为"RCConversationListViewController"类型文件名为头文件
将initwithAppKey改成自己的宏定义
加入视图
self.window.rootViewController = [[RCC alloc]init];
- Rcc 为导入的头文件