跳到主要内容

IMKit 4.X 升级到 5.X

升级到 IMKit 5.4.0

在 IMKit 5.4.0 版本中,SDK 内部移除了对 RongIMLib 的依赖。

如果您从低版本升级至 IMKit 5.4.0,且项目中调用了 RCIMClient 类的方法,可能会出现报错。如果遇到问题,请将 RCIMClient 方法改为调用 RCCoreClient 的同名方法。

IMKit 的以下文档中曾使用 RCIMClient 核心类,现已更新为使用 RCCoreClient 核心类.

例外情况:如果您在 IMKit 的项目中使用聊天室业务,请将调用 RCIMClient 下方法改为调用 RCChatRoomClient 下的同名方法。

从 2.X/4.X 版本升级到 IMKit 5.X 版本

从 2.x / 4.x 版本的 IMKit 升级到 5.x 版本,均涉及到以下相关内容的变更,如果没用到以下内容可以平滑升级:

  • RCIM
  • RCMessageCell
  • RCChatSessionInputBarControl
  • RCPluginBoardView
  • 会话设置页删除:RCSettingViewController 和RCConversationSettingTableViewController
  • RCImagePreviewController
  • RCKitUtility
  • 资源图片变动
  • 消息气泡拉伸比例修改
  • 音视频资源图片迁移
  • 注册自定义消息 cell 时机

下面请看详细介绍:

1.RCIM 的接口

从 4.x 版本升级到 5.x, 需要关注配置属性调用类变更。

/// RCIM 的废弃接口,配置已被移动到 RCKitConfig 类中
@interface RCIM (Deprecated)

@property (nonatomic, assign) BOOL disableMessageNotificaiton __deprecated_msg("已废弃,请使用 RCKitConfigCenter.message.disableMessageNotificaiton");

@property (nonatomic, assign) BOOL disableMessageAlertSound __deprecated_msg("已废弃,请使用 RCKitConfigCenter.message.disableMessageAlertSound");

@property (nonatomic, assign) BOOL enableTypingStatus __deprecated_msg("已废弃,请使用 RCKitConfigCenter.message.enableTypingStatus");

@property (nonatomic, copy) NSArray *enabledReadReceiptConversationTypeList __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.enabledReadReceiptConversationTypeList,设置开启回执的会话类型。");

@property (nonatomic, assign) NSUInteger maxReadRequestDuration __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.maxReadRequestDuration");

@property (nonatomic, assign) BOOL enableSyncReadStatus __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.enableSyncReadStatus");

@property (nonatomic, assign) BOOL enableMessageMentioned __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.enableMessageMentioned");

@property (nonatomic, assign) BOOL enableMessageRecall __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.enableMessageRecall");

@property (nonatomic, assign) NSUInteger maxRecallDuration __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.maxRecallDuration");

@property (nonatomic, assign) BOOL showUnkownMessage __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.showUnkownMessage");

@property (nonatomic, assign) BOOL showUnkownMessageNotificaiton __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.showUnkownMessageNotificaiton");

@property (nonatomic, assign) NSUInteger maxVoiceDuration __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.maxVoiceDuration");

@property (nonatomic, assign) BOOL isExclusiveSoundPlayer __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.isExclusiveSoundPlayer");

@property (nonatomic, assign) BOOL isMediaSelectorContainVideo __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.isMediaSelectorContainVideo");

@property (nonatomic, assign) NSInteger GIFMsgAutoDownloadSize __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.GIFMsgAutoDownloadSize");

@property (nonatomic, assign) BOOL enableSendCombineMessage __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.enableSendCombineMessage");

@property (nonatomic, assign) BOOL enableBurnMessage __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.enableDestructMessage");

@property (nonatomic, assign) NSUInteger reeditDuration __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.reeditDuration");

@property (nonatomic, assign) BOOL enableMessageReference __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.enableMessageReference");

@property (nonatomic, assign) NSUInteger sightRecordMaxDuration __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.message.sightRecordMaxDuration");

@property (nonatomic, strong) UIColor *globalNavigationBarTintColor __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.ui.globalNavigationBarTintColor");

@property (nonatomic, assign) RCUserAvatarStyle globalConversationAvatarStyle __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.ui.globalConversationAvatarStyle");

@property (nonatomic, assign) CGSize globalConversationPortraitSize __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.ui.globalConversationPortraitSize");

@property (nonatomic, assign) RCUserAvatarStyle globalMessageAvatarStyle __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.ui.globalMessageAvatarStyle");

@property (nonatomic, assign) CGSize globalMessagePortraitSize __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.ui.globalMessagePortraitSize");

@property (nonatomic, assign) CGFloat portraitImageViewCornerRadius __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.ui.portraitImageViewCornerRadius");

@property (nonatomic, assign) BOOL enableDarkMode __deprecated_msg(
"已废弃,请使用 RCKitConfigCenter.ui.enableDarkMode");
@end

2.RCMessageCell

@property (nonatomic, strong) UIView *messageHasReadStatusView;

上面接口已废弃删除,可用原有的 statusContentView 替代

3.RCChatSessionInputBarControl

3.1 方法删除

- (void)imageDidSelect:(NSArray *)selectedImages fullImageRequired:(BOOL)full __deprecated_msg("已废弃,请勿使用。");

上面代理方法删除,请用以下方法替代

- (void)imageDataDidSelect:(NSArray *)selectedImages fullImageRequired:(BOOL)full;

3.2 RCChatSessionInputBarControl 类里的枚举均迁移到 RCExtensionKitDefine 类中

4.RCPluginBoardView

插入或者更新扩展面板 button的方法均更改,具体是每个方法增加了一个 highlightedImage 参数,主要是给 PluginBoardItem 增加点击状态的图片

/*!
向扩展功能板中插入扩展项

@param normalImage 扩展项的展示图片
@param highlightedImage 扩展项的触摸高亮图片
@param title 扩展项的展示标题
@param index 需要添加到的索引值
@param tag 扩展项的唯一标示符

@discussion 您以在RCConversationViewController的viewdidload后,添加自定义的扩展项。
SDK默认的扩展项的唯一标示符为1XXX,我们建议您在自定义扩展功能时不要选用1XXX,以免与SDK预留的扩展项唯一标示符重复。
*/
- (void)insertItem:(UIImage *)normalImage highlightedImage:(UIImage *)highlightedImage title:(NSString *)title atIndex:(NSInteger)index tag:(NSInteger)tag;

/*!
添加扩展项到扩展功能板,并在显示为最后一项

@param normalImage 扩展项的展示图片
@param highlightedImage 扩展项的触摸高亮图片
@param title 扩展项的展示标题
@param tag 扩展项的唯一标示符

@discussion 您以在RCConversationViewController的viewdidload后,添加自定义的扩展项。
SDK默认的扩展项的唯一标示符为1XXX,我们建议您在自定义扩展功能时不要选用1XXX,以免与SDK预留的扩展项唯一标示符重复。
*/
- (void)insertItem:(UIImage *)normalImage highlightedImage:(UIImage *)highlightedImage title:(NSString *)title tag:(NSInteger)tag;

/*!
更新指定扩展项

@param index 扩展项的索引值
@param normalImage 扩展项的展示图片
@param highlightedImage 扩展项的触摸高亮图片
@param title 扩展项的展示标题
*/
- (void)updateItemAtIndex:(NSInteger)index normalImage:(UIImage *)normalImage highlightedImage:(UIImage *)highlightedImage title:(NSString *)title;

/*!
更新指定扩展项

@param tag 扩展项的唯一标示符
@param normalImage 扩展项的展示图片
@param highlightedImage 扩展项的触摸高亮图片
@param title 扩展项的展示标题
*/
- (void)updateItemWithTag:(NSInteger)tag normalImage:(UIImage *)normalImage highlightedImage:(UIImage *)highlightedImage title:(NSString *)title;

5. 设置页面类删除

RCSettingViewControllerRCConversationSettingTableViewController会话设置类已移除,如果需要,可以参考官网 SealTalk demo 源码中的 RCDSettingViewController,RCDPrivateSettingsTableViewController 及 RCDGroupSettingsTableViewController 来实现会话设置页

6. RCImagePreviewController

RCImagePreviewController 类(会话页面预览单个图片消息控制器)已移除,可以用 RCImageSlideController 类替代,具体实现参考

RCImageSlideController *imagePreviewVC = [[RCImageSlideController alloc] init];
imagePreviewVC.messageModel = model;
imagePreviewVC.onlyPreviewCurrentMessage = YES;//是否只预览当前图片消息,默认为 NO,支持当前会话图片消息滑动预览,如果设置为 YES, 只预览当前图片消息
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:imagePreviewVC];
nav.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:nav animated:YES completion:nil];

7.RCKitUtility

RCKitUtility 工具类中下面方法已移除,请使用 RCAlertView 中对应的方法

+ (void)showAlertController:(NSString *)title
message:(NSString *)message
preferredStyle:(UIAlertControllerStyle)style
actions:(NSArray<UIAlertAction *> *)actions
inViewController:(UIViewController *)controller;

8. 资源图片名称修改

会话页面输入栏加号扩展中的图片命名替换为 plugin_item 为前缀类型的命名;

输入框切换语音输入按钮表情按钮加号按钮的 icon 替换为 inputbar_xxx 类型的命名。

如果开发者之前直接替换过 SDK 上述资源图片,请注意修改对应图片名称

9. 消息气泡拉伸比例修改

/// 原来的拉伸比例:
UIEdgeInsetsMake(image.size.height * 0.8, image.size.width * 0.2, image.size.height * 0.2, image.size.width * 0.8)

/// 修改后的拉伸比例:
UIEdgeInsetsMake(image.size.height * 0.5, image.size.width * 0.5, image.size.height * 0.5, image.size.width * 0.5)

10. 音视频资源图片变更

RongIMKit 中不再包含 RongCallKit 库中所需的图片资源和语言文件,已转移到 RongCallKit 库中

11.注册自定义消息 cell 时机

如果有自定义消息 Cell,在会话页面 viewDidload 方法中必须优先注册自定义 Cell,再做其他操作