self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ZHUViewController alloc]init]];
[self way];
return YES;
点击列表 继承RCConversationViewController
-(void)way
{
[[RCIM sharedRCIM] initWithAppKey:@"qd46yzrfqdi6f"];
[[RCIM sharedRCIM] connectWithToken:@"Ddoz6mf/VrWFN1AAb4i5E+bFt42+r8+iw8HrsuR8LLmQVFj/48/gjl1hZIgju/d7Pi8ZjtcnWKjidBkoRXEuzA==" success:^(NSString *userId)
{
NSLog(@"登陆成功。当前登录的用户ID:%@", userId);
[[RCIM sharedRCIM] setUserInfoDataSource:self];
}
error:^(RCConnectErrorCode status)
{
NSLog(@"登陆的错误码为:%d", (int)status);
}
tokenIncorrect:^{
//token过期或者不正确。
//如果设置了token有效期并且token过期,请重新请求您的服务器获取新的token
//如果没有设置token有效期却提示token错误,请检查您客户端和服务器的appkey是否匹配,还有检查您获取token的流程。
NSLog(@"token错误");
}];
}
- (void)getUserInfoWithUserId:(NSString *)userId
completion:(void (^)(RCUserInfo *userInfo))completion
{
if ([userId isEqualToString:@"30000001"])
{
RCUserInfo *userInfo = [[RCUserInfo alloc] init];
userInfo.userId = userId;
userInfo.name = @"阿辉";
userInfo.portraitUri = @"http://pic30.photophoto.cn/20140318/0036036898237189_b.jpg";
return completion(userInfo);
}
return completion(nil);
}
客服界面,继承 RCConversationListViewController
[super viewDidLoad];
// Do any additional setup after loading the view.
[self setDisplayConversationTypes:@[@(ConversationType_PRIVATE),
@(ConversationType_DISCUSSION),
@(ConversationType_CHATROOM),
@(ConversationType_GROUP),
@(ConversationType_APPSERVICE),
@(ConversationType_SYSTEM)]];
//设置需要将哪些类型的会话在会话列表中聚合显示
[self setCollectionConversationType:@[@(ConversationType_DISCUSSION),
@(ConversationType_GROUP)]];
//重写RCConversationListViewController的onSelectedTableRow事件
- (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];
}
聊天界面
继承与//两个控制器#import "LTViewController.h"#import "LTTwoViewController.h"//库#import<RongIMKit/RongIMKit.h>//继承
#import "RCDCustomerServiceViewController.h"
//自己写的方法 视图即将可见时调用
-(void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBar.hidden = NO;
}
//点击聊天界面
- (IBAction)LiaoTian:(id)sender {
RCConversationViewController *chat = [[RCConversationViewController alloc] init];
//设置会话的类型,如单聊、讨论组、群聊、聊天室、客服、公众服务会话等
chat.conversationType = ConversationType_PRIVATE;
//设置会话的目标会话ID。(单聊、客服、公众服务会话为对方的ID,讨论组、群聊、聊天室为会话的ID)
chat.targetId = @"30000001";
//设置聊天会话界面要显示的标题
chat.title = @"想显示的会话标题";
//显示聊天会话界面
[self.navigationController pushViewController:chat animated:YES];
}
//点击列表界面
- (IBAction)DianJi:(id)sender {
LTTwoViewController *lttwo = [[LTTwoViewController alloc] init];
[self.navigationController pushViewController:lttwo animated:YES];
}
//机器人
- (IBAction)JQR:(id)sender {
RCDCustomerServiceViewController *chatService = [[RCDCustomerServiceViewController alloc] init];
#define SERVICE_ID @"KEFU148292606720649"
chatService.conversationType = ConversationType_CUSTOMERSERVICE;
chatService.targetId = SERVICE_ID;
chatService.title = @"客服";
//chatService.csInfo = csInfo; //用户的详细信息,此数据用于上传用户信息到客服后台,数据的nickName和portraitUrl必须填写。(目前该字段暂时没用到,客服后台显示的用户信息是你获取token时传的参数,之后会用到)
[self.navigationController pushViewController :chatService animated:YES];
}