融云嵌入简单聊天功能

1、注册应用,获取appkey

image.png

2、集成融云kit和lib,导入第三方库

在 Podfile 文件中添加下面内容,然后pod install

pod 'RongCloudIM/IMKit', '~> 4.0.0.1'
pod 'RongCloudIM/IMLib', '~> 4.0.0.1'

3、注册appkey

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[RCIM sharedRCIM] initWithAppKey:@"获取到的 AppKey"];
    return YES;
}

4、问后台开发人员要token,连接融云服务器

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[RCIM sharedRCIM] initWithAppKey:@"获取到的 AppKey"];

    [[RCIM sharedRCIM] connectWithToken:@"开发者的 server 通过请求 server api 获取到的 token 值"
                           dbOpened:^(RCDBErrorCode code) {}
                            success:^(NSString *userId) {}
                              error:^(RCConnectErrorCode status) {}];

    return YES;
}

5、创建会话界面 继承于RCConversationViewController

传入targetid,即对方的userid,进入会话页

RCDConversationViewController *conversationVC = [[RCDConversationViewController alloc] initWithConversationType:ConversationType_PRIVATE targetId:@"targetId"];
[self.navigationController pushViewController:conversationVC animated:YES];
image.png

你可能感兴趣的:(融云嵌入简单聊天功能)