chat-uikit 1.2.0

chat-uikit 1.2.0

王志AgoraBuilder维护。



 
依赖项
Agora_Chat_iOS>= 1.2.0
EMVoiceConvert= 0.1.0
MJRefresh>= 0
 

  • 作者
  • agora

开始使用Agora Chat UIKit for iOS

Agora Chat UIKit for iOS是在Agora Chat SDK之上的UI组件库。它提供了一系列通用UI组件,如会话列表和聊天UI,让开发者可以轻松地打造满足实际业务需求的聊天应用。此外,这个库通过调用Agora Chat SDK中的方法以实现聊天相关逻辑和数据处理的操作,允许开发者只关注自己的业务和个人化扩展。

Agora Chat UIKit for iOS的源代码URL

Agora Chat UIKit for iOS应用的URL

重要功能

  • 消息扩展功能
    • 表情回应
    • 消息线程
    • 回复消息
    • 聊天群组@提及
    • 修改已发送消息
    • 撤回已发送消息
    • 转发消息
  • 公共功能
    • 会话列表
    • 在会话中进行聊天
    • 语音消息
    • 正在输入指示器
    • 交付收据
    • 已读回执

先决条件

系统兼容性

  • chat-uikit:iOS 11.0 及更高版本
  • 聊天应用:iOS 11.0 及更高版本

项目设置

导入 chat-uikit

安装 CocoaPods

  1. 安装 CocoaPods。详细信息,请参阅 CocoaPods 入门指南

  2. 在终端中,打开项目的根目录,并运行 pod init 命令。然后,项目文件夹中会生成文本文件 Podfile

chat-uikit 可以通过 pod 或源代码进行集成。详细步骤如下:

使用pod集成Agora Chat UIKit for iOS

  1. Podfile文件中,添加chat-uikit的依赖。请记得将ProjectName替换为您的项目名称。
platform :ios, '11.0'

# Import CocoaPods sources
source 'https://github.com/CocoaPods/Specs.git'

target 'ProjectName' do
    pod 'chat-uikit'
end
  1. 在Terminal中,运行cd命令切换到Podfile文件所在的目录。然后运行以下命令来集成SDK。
pod install
  1. Pod安装完成后,Terminal中将显示Pod installation complete!信息。此时,在项目文件夹中将生成新的xcworkspace文件。您可以打开此新文件来运行项目。

注意

根据AgoraChat SDK,chat-uikit提供了拍照、发送语音消息、图片消息以及附件等功能,需要访问录音、相机和相册。因此,您需要在info.plist中添加相关的权限。

通过源代码集成Agora Chat UIKit for iOS
  1. 从github下载源代码

下载地址: https://github.com/AgoraIO-Usecase/AgoraChat-UIKit-ios.git

Terminal命令:git clone https://github.com/AgoraIO-Usecase/AgoraChat-UIKit-ios.git

  1. 在项目中添加chat-uikit的源代码依赖。

打开Podfile文件,添加chat-uikit的依赖。

Podfile文件示例

platform :ios, '11.0'

source 'https://github.com/CocoaPods/Specs.git'

target 'ProjectName' do
    pod 'chat-uikit',  :path => "../chat-uikit"
end

#The chat-uikit path should point to the directory where chat-uikit.podspec resides.
  1. 在项目中集成本地Agora Chat UIKit for iOS源代码。

在Terminal中,运行cd命令切换到Podfile文件所在的目录。然后运行pod install命令来安装Agora Chat UIKit for iOS的本地源代码。

命令执行完成后,您可以在Xcode项目的Pods/Development Pods/目录中找到Agora Chat UIKit for iOS的源代码,并将其修改以符合您的项目目标。

添加权限

在您项目的 info.plist 文件中添加权限。

Privacy - Photo Library Usage Description //Album privileges.
Privacy - Microphone Usage Description //Microphone privileges.
Privacy - Camera Usage Description //Camera privileges.
App Transport Security Settings -> Allow Arbitrary Loads //Enable the network service.

参考

如果您在源代码定制过程中进行了任何通用自定义,请将其提交到我们的仓库 https://github.com/AgoraIO-Usecase/AgoraChat-UIKit-ios.git 以成为我们社区的贡献者。

第三部分:初始化

1. 引入头文件

#import <chat-uikit/EaseChatKit.h>

2. 初始化聊天气泡UI Kit

在项目中的 AppDelegate.m 文件中,调用 EaseChatKitManager 的初始化方法来初始化 AgoraChat SDK(注意,不需要反复调用此方法)。

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
	// Override point for customization after application launch.
	AgoraChatOptions *options = [AgoraChatOptions optionsWithAppkey:@"You created APPKEY"];
	[EaseChatKitManager initWithAgoraChatOptions:options];
	//Login operation.
	return YES;
}

3. 获取所有会话未读消息数量的回调

EaseChatKitManagerDelegate 是获取所有会话未读消息总数的回调。

您需要在 EaseChatKitManagerDelegate 中注册您的类以接收未读消息总数变化的回调。

/*
 @method
 @brief   Callback triggered when the total number of unread messages is changed.
 @param   unreadCount     The total number of unread messages in all conversations.
 */

- (void)conversationsUnreadCountUpdate:(NSInteger)unreadCount;

IV. 快速设置

快速设置聊天会话

1. 导入头文件
#import <chat-uikit/EaseChatKit.h>
加载对话页面

Agora Chat UIKit for iOS 提供用于聊天对话的 ViewController。您可以为聊天创建一个 EaseChatViewController 实例,并将 Agora Chat 中的聊天控制器(参见 Agora Chat 的 ACDChatViewController.m)嵌入此实例以集成此库的聊天对话功能。要创建聊天对话页面实例,您需要传递对话 ID、群组 ID、对话类型(AgoraChatConversationType)和 EaseChatViewModel(聊天视图配置数据模型)实例。

EaseChatViewModel *viewModel = [[EaseChatViewModel alloc]init];
EaseChatViewController *chatController = [EaseChatViewController initWithConversationId:@"custom"
                                              conversationType:AgoraChatConversationTypeChat
                                                  chatViewModel:viewModel];
[self addChildViewController:chatController];
[self.view addSubview:chatController.view];
chatController.view.frame = self.view.bounds;

快速设置对话列表

1. 导入头文件。
#import <chat-uikit/EaseChatKit.h>
2. 加载对话列表。

在您的聊天控制器中,可以嵌入 EaseConversationsViewController 用于 Agora Chat UIKit for iOS 的对话列表。

创建对话列表实例。在实例化对话列表时,确保传递 EaseConversationViewModel 实例。

EaseConversationViewModel *viewModel = [[EaseConversationViewModel alloc] init];

EaseConversationsViewController *easeConvsVC = [[EaseConversationsViewController alloc] initWithModel:viewModel];
easeConvsVC.delegate = self;
[self addChildViewController:easeConvsVC];
[self.view addSubview:easeConvsVC.view];
[easeConvsVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
    make.size.equalTo(self.view);
}];

V. 设置样式

设置聊天对话框样式

针对聊天对话框,需要配置以下参数

// The background color of the chat view.
@property (nonatomic, strong) UIColor *chatViewBgColor;

// The background color of the timeline.
@property (nonatomic, strong) UIColor *msgTimeItemBgColor;

// The timeline font.
@property (nonatomic, strong) UIFont *msgTimeItemFont;

// The font color of the timeline.
@property (nonatomic, strong) UIColor *msgTimeItemFontColor;

// The bubble background image of the received message.
@property (nonatomic, strong) UIImage *receiverBubbleBgImage;

// The bubble background image of the sent message.
@property (nonatomic, strong) UIImage *senderBubbleBgImage;

// Right align image/video/attachment message bubble cornerRadius.
@property (nonatomic) BubbleCornerRadius rightAlignmentCornerRadius;

// Left align image/video/attachment message bubble cornerRadius.
@property (nonatomic) BubbleCornerRadius leftAlignmentCornerRadius;

// Message bubble background protected area.
@property (nonatomic) UIEdgeInsets bubbleBgEdgeInsets;

// The font color of the sent message.
@property (nonatomic, strong) UIColor *sentFontColor;

// The font color of the receiver message.
@property (nonatomic, strong) UIColor *reveivedFontColor;

// The font of the text message.
@property (nonatomic) UIFont *textMessaegFont;

// Input menu background color and input menu gradient color mutually exclusive. display background color first.
@property (nonatomic, strong) UIColor *inputMenuBgColor;

// Input menu type.
@property (nonatomic) EaseInputMenuStyle inputMenuStyle;

// Input menu extend view model.
@property (nonatomic) EaseExtendMenuViewModel *extendMenuViewModel;

// Whether to display the sent avatar.
@property (nonatomic) BOOL displaySentAvatar;

// Whether to display the received avatar.
@property (nonatomic) BOOL displayReceivedAvatar;

// Whether to display the sent name.
@property (nonatomic) BOOL displaySentName;

// Whether to display the received name.
@property (nonatomic) BOOL displayReceiverName;

// The avatar style.
@property (nonatomic) EaseChatAvatarStyle avatarStyle;

// The corner radius of the avatar. 
// The default value is 0, indicating that only the rounded corner style is allowed.
@property (nonatomic) CGFloat avatarCornerRadius;

// The message alignment style of in the chat view.
@property (nonatomic) EaseAlignmentStyle msgAlignmentStyle;

extendMenuViewModel(输入区域扩展函数数据配置的模型,如聊天对话框页面上的摄像头或相册区域)包含以下可配置参数

/*
 *  inputMenu "+" extend view style
 */
typedef NS_ENUM(NSInteger, EaseExtendViewStyle) {
    EaseInputMenuExtFuncView = 1,  //inputMenu view
    EasePopupView,                //viewcontroller popup view
};

// The background color of the icon.
@property (nonatomic, strong) UIColor *iconBgColor;

// The background color of the view.
@property (nonatomic, strong) UIColor *viewBgColor;

// The font color.
@property (nonatomic, strong) UIColor *fontColor;

// The font size.
@property (nonatomic, assign) CGFloat fontSize;

// The view size.
@property (nonatomic, assign) CGSize collectionViewSize;

// The extension view style.
@property (nonatomic) EaseExtendViewStyle extendViewStyle;

inputMenuStyle(输入区域)可以是以下样式之一

/*
 *  Input menu style
 */
typedef NS_ENUM(NSInteger, EaseInputMenuStyle) {
    EaseInputMenuStyleAll = 1,          //All functions
    EaseInputMenuStyleNoAudio,          //No Audio
    EaseInputMenuStyleNoEmoji,          //No Emoji
    EaseInputMenuStyleNoAudioAndEmoji,  //No Audio And Emoji
    EaseInputMenuStyleOnlyText,         //Only Text
};

The EaseAlignmentStyle 参数(消息对齐模式,仅适用于群聊)可以是以下消息对齐模式之一

/*
 *  Message alignment
 */
typedef NS_ENUM(NSInteger, EaseAlignmentStyle) {
    EaseAlignmentLeft_Right = 1,     //Left Right alignment
    EaseAlignmentlAll_Left,          //The left alignment
};

实例化的聊天控制器可以通过重置聊天视图 UI 配置模型刷新聊天页面。

// Resets the chat controller.

- (void)resetChatVCWithViewModel:(EaseChatViewModel *)viewModel;
自定义聊天UI

Agora Chat UIKit for iOS使用默认UI样式。您可以通过参考以下段落自定义用户界面。

  • 默认样式的示例

要自定义聊天UI,您只需在EaseChatViewModel实例中修改样式参数,然后将它们传递给EaseChatViewController。

EaseChatViewModel *viewModel = [[EaseChatViewModel alloc]init]; //Default styles.
EaseChatViewController *chatController = [EaseChatViewController initWithConversationId:@"Conversation ID" conversationType:AgoraChatConversationTypeChat chatViewModel:viewModel];

以下是一个使用默认样式的聊天页面的示例

img

  • 使用自定义样式的聊天页面的配置示例

创建一个具有自定义样式的EaseChatViewModel实例,并将其传递给EaseChatViewController的构造函数以供聊天页面使用。

EaseChatViewModel *viewModel = [[EaseChatViewModel alloc]init];
viewModel.chatViewBgColor = [UIColor systemGrayColor];  //The chat background color.
viewModel.inputMenuBgColor = [UIColor systemPinkColor]; //The background color of the input area.
viewModel.sentFontColor = [UIColor redColor];           //The sender's text color.
viewModel.inputMenuStyle = EaseInputMenuStyleNoAudio;   //The menu style of the input area.
viewModel.msgTimeItemFontColor = [UIColor blackColor];  //The message time font color.
viewModel.msgTimeItemBgColor = [UIColor greenColor];    //The background color of the message time area.
EaseChatViewController *chatController = [EaseChatViewController initWithConversationId:@"Conversation ID" conversationType:AgoraChatConversationTypeChat chatViewModel:viewModel];

以下是一些自定义样式配置的示例

img

有关更多API的详细信息,请参阅EaseChatViewController提供的API以及EaseChatViewControllerDelegate协议中的回调API。

配置会话列表样式

对于会话列表,您可以配置以下参数

// Whether to display the chat room. By default, the chat room is displayed.
@property (nonatomic) BOOL displayChatroom;

// The avatar style.
@property (nonatomic) EaseChatAvatarStyle avatarType;

// The avatar size.
@property (nonatomic) CGSize avatarSize;

// The corner radius of the avatar.
@property (nonatomic) CGFloat avatarCornerRadius;

// The avatar edge insets.
@property (nonatomic) UIEdgeInsets avatarEdgeInsets;

// The top style of the conversation.
@property (nonatomic) EaseChatConversationTopStyle conversationTopStyle;

// The top background color of the conversation.
@property (nonatomic, strong) UIColor *conversationTopBgColor;

// The top icon of the conversation.
@property (nonatomic, strong) UIImage *conversationTopIcon;

// The insets of the top icon.
@property (nonatomic) UIEdgeInsets conversationTopIconInsets;

// The size of the top icon.
@property (nonatomic) CGSize conversationTopIconSize;

// The nickname font.  
@property (nonatomic, strong) UIFont *nameLabelFont;

// The nickname color.
@property (nonatomic, strong) UIColor *nameLabelColor;

// The edge insets of the nickname.
@property (nonatomic) UIEdgeInsets nameLabelEdgeInsets;

// The font of message details.
@property (nonatomic, strong) UIFont *detailLabelFont;

// The text font of message details.
@property (nonatomic, strong) UIColor *detailLabelColor;

// The edge insets of message details.
@property (nonatomic) UIEdgeInsets detailLabelEdgeInsets;

// The font of the message time.
@property (nonatomic, strong) UIFont *timeLabelFont;

// The color of the message time.
@property (nonatomic, strong) UIColor *timeLabelColor;

// The location of the message time.
@property (nonatomic) UIEdgeInsets timeLabelEdgeInsets;

// Whether to display the number of unread messages.     
@property (nonatomic) BOOL needsDisplayBadge;

// The position of the unread message badge.
@property (nonatomic) EaseChatUnReadCountViewPosition badgeLabelPosition;

// The style of the unread message badge.
@property (nonatomic) EaseChatUnReadBadgeViewStyle badgeViewStyle;

// The font of the unread message badge. 
@property (nonatomic, strong) UIFont *badgeLabelFont;

// The color of the badge title of the unread messages.
@property (nonatomic, strong) UIColor *badgeLabelTitleColor;

// The background color of the unread message badge.
@property (nonatomic, strong) UIColor *badgeLabelBgColor;

// The height of the unread message badge.
@property (nonatomic) CGFloat badgeLabelHeight;

// The height of the red dot for the unread messages.
@property (nonatomic) CGFloat badgeLabelRedDotHeight;

// The deviation of the unread message badge from the center.
@property (nonatomic) CGVector badgeLabelCenterVector;

// The displayed maximum number of unread messages. If the upper limit is exceeded, the maximum number will be followed by `+`.
@property (nonatomic) int badgeMaxNum;

// The do-not-disturb image.
@property (nonatomic, strong) UIImage *noDisturbImg;

// The insets of the do-not-disturb image.
@property (nonatomic) UIEdgeInsets noDisturbImgInsets;

// The size of the do-not-disturb image.
@property (nonatomic) CGSize noDisturbImgSize;

会话类的父类包含以下可配置参数

// Whether to refresh by pull-down.
@property (nonatomic) BOOL canRefresh;

// The background view of TableView.
@property (nonatomic, strong) UIView *bgView;

// The background color of UITableViewCell.
@property (nonatomic, strong) UIColor *cellBgColor;

// The insets of the dividing line of UITableViewCell.
@property (nonatomic) UIEdgeInsets cellSeparatorInset;

// The color of the dividing line of UITableViewCell.
@property (nonatomic, strong) UIColor *cellSeparatorColor;
定制会话列表UI

Agora Chat UIKit for iOS使用默认的UI样式。您可以通过参考以下段落来定制您的会话列表。

  • 默认样式的示例

要定制会话列表UI,您只需创建一个EaseChatViewModel实例,并将其作为参数传递给EaseChatViewController(聊天页面的构造函数)。

EaseConversationViewModel *viewModel = [[EaseConversationViewModel alloc] init]; //Default styles.
EaseConversationsViewController *chatsVC = [[EaseConversationsViewController alloc] initWithModel:viewModel];

以下图形是默认样式的会话列表示例

img

  • 自定义样式配置示例

创建一个具有自定义样式的EaseChatViewModel实例,并将其传递给EaseChatViewController的构造函数以供聊天页面使用。

EaseConversationViewModel *viewModel = [[EaseConversationViewModel alloc] init];
viewModel.canRefresh = YES;                                //Whether to enable refresh.
viewModel.badgeLabelCenterVector = CGVectorMake(-16, 0);   //The Badge offset of the number of unread messages.
viewModel.avatarType = Rectangular;                        //The avatar type.
viewModel.nameLabelColor = [UIColor blueColor];            //The color of the conversation name.
viewModel.detailLabelColor = [UIColor redColor];           //The color of conversation details.
viewModel.timeLabelColor = [UIColor systemPinkColor];      //The color of conversation time.
viewModel.cellBgColor = [UIColor lightGrayColor];          //The background color of the conversation cell.
viewModel.badgeLabelBgColor = [UIColor purpleColor];       //The background color of the number of unread messages.

EaseConversationsViewController *chatsVC = [[EaseConversationsViewController alloc] initWithModel:viewModel];

以下是一些自定义样式配置的示例

img

有关更多API的详细信息,请参阅EaseConversationsViewController提供的API以及EaseConversationsViewControllerDelegate协议中的回调API。

自定义功能扩展

自定义会话功能扩展

在EaseChatViewController实例化之后,您可以实现EaseChatViewControllerDelegate协议(聊天控制器回调代理)以接收EaseChatViewController的回调并进一步实现自定义扩展。

EaseChatViewControllerDelegate

自定义消息单元的回调

您可以通过实现会话列表回调协议来获取自定义消息单元。

如果返回nil,则使用默认消息单元;如果返回单元,则使用自定义消息单元。

/**
 * Customize cell.
 *
 * @param tableView        The table view of the current message view.
 * @param messageModel     The message data model.
 *
 */
- (UITableViewCell *)cellForItem:(UITableView *)tableView messageModel:(EaseMessageModel *)messageModel;
所选消息的回调

所选消息的回调(chat-uikit已经提供了所选消息单元的回调,您需要自行实现回调)。

/**
 * Message click callback.
   
 * It returns whether the default click event needs to be executed: 
 * - `YES`: The event needs to be executed.
 * - `NO`: The event does not need to be executed.
 *
 * @param   message         The selected message.
 * @param   userData        The user profile contained in the selected message.
 *
 */
- (BOOL)didSelectMessageItem:(AgoraChatMessage *)message userProfile:(id<EaseUserProfile>)userData;
用户个人资料回调

用户个人资料的回调(例如头像和昵称)。

/**
 * User profile callback
 *
 * @discussion  Users will match the user ID against those in their own user system. If a match is found, the related user profile is returned; if `nil` is returned, the default implementation is used.
 *
 * @param   userID        The user ID.
 *
 */
- (id<EaseUserProfile>)userProfile:(NSString *)userID;

Chat应用中用户个人资料回调的示例

- (id<EaseUserProfile>)userProfile:(NSString *)userID
{
    AgoraChatUserDataModel *model = nil;
    AgoraChatUserInfo* userInfo = [[UserInfoStore sharedInstance] getUserInfoById:userID];
    if(userInfo) {
        model = [[AgoraChatUserDataModel alloc]initWithUserInfo:userInfo];
    }else{
        [[UserInfoStore sharedInstance] fetchUserInfosFromServer:@[userID]];
    }
    return model;
}
所选头像的回调
/**
 * Occurs when an avatar is selected.
 *
 * @param   userData        The user profile that contains the selected avatar.
 *
 */
- (void)avatarDidSelected:(id<EaseUserProfile>)userData;
按住头像的回调
/**
 * Occurs when the avatar is held down.
 *
 * @param   userData        Occurs when the avatar is held down.
 *
 */
- (void)avatarDidLongPress:(id<EaseUserProfile>)userData;
输入区域的回调

当前对话输入扩展区域的数据模型组(聊天视图的配置数据模型中可以实现 UI 配置)。

/**
 * The data model group for the input extension area.
 *
 * @param   defaultInputBarItems        The data model group for the input extension area (default order: album, camera attachments).
 * @param   conversationType            The current conversation type: single chat, group chat, chat room.
 *
 */
- (NSMutableArray<EaseExtendMenuModel *> *)inputBarExtMenuItemArray:(NSMutableArray<EaseExtendMenuModel*>*)defaultInputBarItems conversationType:(AgoraChatConversationType)conversationType;
键盘输入变化的回调
/**
 * Example of callback for a keyboard input change in the input area: @ group member
 *
 * @brief Example of callback for a keyboard input change: @ group member
 */
- (BOOL)textView:(UITextView*)textView ShouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
其他方的输入状态回调

对方正在输入时触发的回调。此回调仅适用于一对一聊天。

/**
 * Occurs when the peer user is typing during a one-to-one chat.
 */
- (void)peerTyping;

对方完成输入时触发的回调。此回调仅适用于一对一聊天。

/**
 * Occurs when the peer user completes typing.
 */
- (void)peerEndTyping;
点击钛象到数时机事件的回复
点击钛象到数时间下的短点击事件错误的回复
/**
 * Occurs when the default message cell is held down.
 *
 * @param   defaultLongPressItems   A list of action options (copy, delete, and recall) shown when the default message cell is held down (the delivery time is less than 2 minutes).
 * @param   message                  The default message cell.
 *
 */
- (NSMutableArray<EaseExtendMenuModel *> *)messageLongPressExtMenuItemArray:(NSMutableArray<EaseExtendMenuModel*>*)defaultLongPressItems message:(AgoraChatMessage*)message;
点击钛象到数时间点击模式下的长按模式下的时间内在错误的回复

点击钛象到数时间点击模式下的长按模式下的时间内在错误的回复。

/**
 * Occurs when a custom message cell is held down.
 *
 * @param   defaultLongPressItems       A list of default action options (copy, delete, and recall) shown when a custom message cell is held down (the delivery time is less than 2 minutes).
 * @param   customCell                  The custom message cell that is held down.
 */
- (NSMutableArray<EaseExtendMenuModel *> *)customCellLongPressExtMenuItemArray:(NSMutableArray<EaseExtendMenuModel*>*)defaultLongPressItems customCell:(UITableViewCell*)customCell;

文案化的conversation list功能扩展

实例化EaseConversationsViewController后,您可以通过实现EaseConversationsViewControllerDelegate协议(会话列表回调代理)来接收EaseConversationsViewController的回调,然后进一步实现自定义扩展。

EaseConversationsViewControllerDelegate

自定义会话单元格回调

您可以通过实现会话列表回调来获取自定义会话单元格。

如果返回nil,则将使用默认会话单元格;如果返回单元格,则使用自定义会话单元格。

/*
 *@method
 *@brief  Occurs when a custom conversation cell is used.
 *@discussion  Returns nil to use the default cell; otherwise, a custom cell will be used.
 *@param  tableView  The table view of the current message view.
 *@param  indexPath  The indexPath of the conversation cell.
 *@result The custom conversation cell.
 */
- (EaseConversationCell *)easeTableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
会话列表中单元格选择的回调
/*
 *@method
 *@brief     Occurs when a cell is selected on the conversation list.
 *@param     tableView        The table view of the current message view.
 *@param     indexPath        The indexPath of the cell for sideslip.
 */
- (void)easeTableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
//Example for cell selection on the conversation list (valid only for the Chat app).
  
- (void)easeTableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    EaseConversationCell *cell = (EaseConversationCell*)[tableView cellForRowAtIndexPath:indexPath];
    ACDChatViewController *chatViewController = [[ACDChatViewController alloc] initWithConversationId:cell.model.easeId conversationType:cell.model.type];
    chatViewController.navTitle = cell.model.showName;
    chatViewController.hidesBottomBarWhenPushed = YES;
  
    //Jump to the chat page.
    [self.navigationController pushViewController:chatViewController animated:YES];
}
会话列表用户个人资料回调
/*
 @method
 @brief         Callback for the user profile of the conversation list.
 @discussion    The user profile dataset can be returned according to the ID or type of conversation.
 @param   conversationId    The conversation ID.
 @param   type              The conversation Type.
 */
- (id<EaseUserProfile>)easeUserProfileAtConversationId:(NSString *)conversationId
                                      conversationType:(AgoraChatConversationType)type;
//Example of callback for the user profile of the conversation list (valid only for the Chat app).

- (id<EaseUserProfile>)easeUserProfileAtConversationId:(NSString *)conversationId conversationType:(AgoraChatConversationType)type
{
    AgoraChatConvUserDataModel *userData = nil;
    if(type == AgoraChatConversationTypeChat) {
        AgoraChatUserInfo* userInfo = [[UserInfoStore sharedInstance] getUserInfoById:conversationId];
        if(userInfo) {
            userData = [[AgoraChatConvUserDataModel alloc]initWithUserInfo:userInfo conversationType:type];
        }else{
            [[UserInfoStore sharedInstance] fetchUserInfosFromServer:@[conversationId]];
        }
    }
    return userData;
}
会话列表单元格侧滑项回调
/*
 *@method
 *@brief     Occurs when a cell on the conversation list sideslips.
 *@param     tableView     tableView of the current message view.
 *@param     indexPath     The indexPath of the cell for sideslip.
 *@param     actions       A collection of cell sideslip items.
 */
- (NSArray<UIContextualAction *> *)easeTableView:(UITableView *)tableView
      trailingSwipeActionsForRowAtIndexPath:(NSIndexPath *)indexPath
                                    actions:(NSArray<UIContextualAction *> *)actions;
会话列表单元格侧滑状态回调
- (void)easeTableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath;

- (void)easeTableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath;

直播聊天室

1.直播聊天室的消息列表

创建直播聊天室的消息列表
/// Initializes a chat view.
/// @param frame           The frame of the chat view.
/// @param chatroom        An Agora chat room.
/// @param customMsgHelper The custom message helper.
/// @param customOption    The custom option of the chat view.
- (instancetype)initWithFrame:(CGRect)frame
                     chatroom:(AgoraChatroom*)chatroom
              customMsgHelper:(EaseCustomMessageHelper*)customMsgHelper
                 customOption:(EaseChatViewCustomOption *)customOption;
在聊天室发送礼物消息
/// Sends a gift.
/// @param giftId  The gift ID.
/// @param num     The number of gifts.
/// @param aCompletion The callback for sending a gift message.
- (void)sendGiftAction:(NSString *)giftId
                   num:(NSInteger)num
            completion:(void (^)(BOOL success))aCompletion;
是否显示聊天视图
/// Whether to display or hide the chat view.
/// @param isHidden Whether to hide the chat view.
- (void)updateChatViewWithHidden:(BOOL)isHidden;
更新sendTextButton的标题
/// Updates the title of sendTextButton.
/// @param hint sendTextButton title
- (void)updateSendTextButtonHint:(NSString *)hint;
聊天室代理方法
自定义消息单元格
/// Displays the custom message cell position, i.e., the indexpath in the table view.
/// @param indexPath indexPath
- (UITableViewCell *)easeMessageCellForRowAtIndexPath:(NSIndexPath *)indexPath;
自定义消息单元格的高度
/// Displays the height of the custom message cell.
/// @param indexPath indexPath
- (CGFloat)easeMessageCellHeightAtIndexPath:(NSIndexPath *)indexPath;
自定义连接单元格
/// Displays the custom join cell.
/// @param indexPath indexPath
- (UITableViewCell *)easeJoinCellForRowAtIndexPath:(NSIndexPath *)indexPath;
自定义连接单元格的高度
/// Displays the height of the custom join cell.
/// @param indexPath indexPath
- (CGFloat)easeJoinCellHeightAtIndexPath:(NSIndexPath *)indexPath;
消息点击回调
/// The message tap callback.
/// @param message  The tapped message.
- (void)didSelectUserWithMessage:(AgoraChatMessage*)message;
弹出输入框的回调
/// Changes the offset of the chat view from the bottom edge of the current window. 
/// @param offset  The offset of the chat view from the bottom edge of the current window.
- (void)chatViewDidBottomOffset:(CGFloat)offset;
消息发送回调
/// Sends a message in the EaseChatView.
/// @param message The message that is sent.
/// @param error The error information.
- (void)chatViewDidSendMessage:(AgoraChatMessage *)message
                         error:(AgoraChatError *)error;
2. 设置自定义聊天室选项
/**
 * Set the custom message cell in the EaseChatView.   
 */
@property (nonatomic, assign) BOOL customMessageCell;
/**
 * Set the custom join cell.
 */
@property (nonatomic, assign) BOOL customJoinCell;

/**
 * Set the background color of the EaseChatView.
 */
@property (nonatomic, strong) UIColor *tableViewBgColor;

/**
 * Set the right margin of EaseChatView.
 */
@property (nonatomic, assign) CGFloat tableViewRightMargin;

/**
 * Set the bottom margin of the sendTextButton of EaseChatView.
 */
@property (nonatomic, assign) CGFloat sendTextButtonBottomMargin;

/**
 * Set the right margin of the sendTextButton of EaseChatView.
 */
@property (nonatomic, assign) CGFloat sendTextButtonRightMargin;

/**
 * Set whether to display the sender avatar view.
 */
@property (nonatomic, assign) BOOL   displaySenderAvatar;

/**
 * Set whether to display the sender nickname.
 */
@property (nonatomic, assign) BOOL   displaySenderNickname;

/**
 * Set the avatar style.
 */
@property (nonatomic) EaseChatAvatarStyle avatarStyle;

/**
 * Set the corner radius of the avatar.
 * 
 * The default value is 0, indicating that only the rounded corner style is allowed.
 */
@property (nonatomic) CGFloat avatarCornerRadius;

/**
 * Set the background color of the content view of a message cell.
 */
@property (nonatomic, strong) UIColor *cellBgColor;

/**
 * Set the text font size of the name label.
 */
@property (nonatomic, assign) CGFloat nameLabelFontSize;
/**
 * Set the text color of the name label.
 */
@property (nonatomic, strong) UIColor *nameLabelColor;
/**
 * Set the font size of the message label.
 */
@property (nonatomic, assign) CGFloat messageLabelSize;

/**
 * Set the text color of the message label.
 */
@property (nonatomic, strong) UIColor *messageLabelColor;
3. 发送自定义消息
创建自定义消息助手类
/// Creates a EaseCustomMessageHelper instance.
/// @param customMsgImp   The delegate which implements EaseCustomMessageHelperDelegate.
/// @param chatId         The chat room ID.
- (instancetype)initWithCustomMsgImp:(id<EaseCustomMessageHelperDelegate>)customMsgImp chatId:(NSString*)chatId;
发送自定义消息
/*
 Sends a custom message (such as a gift, like, or barrage).
 @param text                 The message content.
 @param num                  Number of message content
 @param messageType          chat type
 @param customMsgType        The custom message type
 @param aCompletionBlock     The completion block.
*/
- (void)sendCustomMessage:(NSString*)text
                      num:(NSInteger)num
                       to:(NSString*)toUser
              messageType:(AgoraChatType)messageType
            customMsgType:(customMessageType)customMsgType
               completion:(void (^)(AgoraChatMessage *message, AgoraChatError *error))aCompletionBlock;
使用扩展参数发送自定义消息
/*
 Sends a custom message (such as a gift, like, or barrage) (with extension parameters).
 @param text                 The message content.
 @param num                  Number of message content
 @param messageType          chat type
 @param customMsgType        The custom message type
 @param ext                  The message extension.
 @param aCompletionBlock     The completion block.
*/
- (void)sendCustomMessage:(NSString*)text
                      num:(NSInteger)num
                       to:(NSString*)toUser
              messageType:(AgoraChatType)messageType
            customMsgType:(customMessageType)customMsgType
                      ext:(NSDictionary*)ext
               completion:(void (^)(AgoraChatMessage *message, AgoraChatError *error))aCompletionBlock;
发送自定义消息体的事件(其他自定义消息体事件)
/*
 Sends a custom message (other custom message body events).
 
@param event                The event for sending a custom message body.
@param customMsgBodyExt     The extension parameters in the custom message body.
@param to                   The message recipient.
@param messageType          The message type.
@param aCompletionBlock     The completion block.
*/
- (void)sendUserCustomMessage:(NSString*)event
             customMsgBodyExt:(NSDictionary*)customMsgBodyExt
                           to:(NSString*)toUser
                  messageType:(AgoraChatType)messageType
                   completion:(void (^)(AgoraChatMessage *message, AgoraChatError *error))aCompletionBlock;
发送带有扩展参数的自定义消息体的事件
/*
 Sends a custom message (Other custom message body events) (extension parameters).
 
@param event                The event for sending a custom message body.
@param customMsgBodyExt     The extension parameters in the custom message body.
@param to                   The message recipient.
@param messageType          The message type.
@param ext                  The message extension.
@param aCompletionBlock     The completion block.
*/
- (void)sendUserCustomMessage:(NSString*)event
             customMsgBodyExt:(NSDictionary*)customMsgBodyExt
                           to:(NSString*)toUser
                  messageType:(AgoraChatType)messageType
                          ext:(NSDictionary*)ext
                   completion:(void (^)(AgoraChatMessage *message, AgoraChatError *error))aCompletionBlock;
4. 获取用户信息
创建用户信息管理器辅助类
/// create EaseUserInfoManagerHelper instance.
+ (EaseUserInfoManagerHelper *)sharedHelper;
根据用户ID获取用户信息
/// Gets user information.
/// @param userIds The user IDs.
/// @param completion The completion block.
+ (void)fetchUserInfoWithUserIds:(NSArray<NSString *> *)userIds
                      completion:(void(^)(NSDictionary *userInfoDic))completion;
根据用户ID和信息类型获取用户信息
/// Gets user information by user ID and information type.
/// @param userIds The user IDs.
/// @param userInfoTypes The user information types.
/// @param completion The completion block.
+ (void)fetchUserInfoWithUserIds:(NSArray<NSString *> *)userIds
                   userInfoTypes:(NSArray<NSNumber *> *)userInfoTypes
                      completion:(void(^)(NSDictionary *userInfoDic))completion;
更新用户信息
/// Updates user information.
/// @param userInfo The user information.
/// @param completion The completion block.
+ (void)updateUserInfo:(AgoraChatUserInfo *)userInfo
            completion:(void(^)(AgoraChatUserInfo *aUserInfo))completion;
按用户ID更新用户信息
/// Updates user information by user ID.
/// @param userId The user ID.
/// @param type The user information type.
/// @param completion The completion block.
+ (void)updateUserInfoWithUserId:(NSString *)userId
                        withType:(AgoraChatUserInfoType)type
                      completion:(void(^)(AgoraChatUserInfo *aUserInfo))completion;
获取当前登录用户的信息
/// Gets the information of the current logged-in user.
/// @param completion The completion block.
+ (void)fetchOwnUserInfoCompletion:(void(^)(AgoraChatUserInfo *ownUserInfo))completion;
+ ```