IMAMsg.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //
  2. // IMAMsg.h
  3. // TIMAdapter
  4. //
  5. // Created by AlexiChen on 16/1/29.
  6. // Copyright © 2016年 AlexiChen. All rights reserved.
  7. //
  8. typedef NS_ENUM(NSInteger, IMAMSGType) {
  9. EIMAMSG_Unknown, // 未知消息类型
  10. EIMAMSG_Text, // 文本
  11. EIMAMSG_Image, // 图片
  12. EIMAMSG_File, // 文件
  13. EIMAMSG_Sound, // 语音
  14. EIMAMSG_Face, // 表情
  15. EIMAMSG_Location, // 定位
  16. EIMAMSG_Video, // 视频消息
  17. EIMAMSG_Custom, // 自定义
  18. EIMAMSG_TimeTip, // 时间提醒标签,不存在于IMSDK缓存的数据库中,业务动态生成
  19. EIMAMSG_GroupTips, // 群提醒
  20. EIMAMSG_GroupSystem, // 群系统消息
  21. EIMAMSG_SNSSystem, // 关系链消息
  22. EIMAMSG_ProfileSystem, // 资料变更消息
  23. EIMAMSG_InputStatus, // 对方输入状态
  24. EIMAMSG_SaftyTip, // 敏感词消息提醒标签,不存在缓存中,退出聊天界面再进入,则不存在了
  25. EIMAMSG_RevokedTip, // 消息撤回
  26. #if kTestChatAttachment
  27. EIMAMSG_Multi, // 富文消息,后期所有聊天消息全部使用富文本显示
  28. #endif
  29. };
  30. /**
  31. * 消息状态
  32. */
  33. typedef NS_ENUM(NSInteger, IMAMsgStatus)
  34. {
  35. EIMAMsg_Init = -1, // 初始化, 为兼容TIMMessageStatus,从-1开始,创建的消息
  36. EIMAMsg_WillSending, // 即将发送,加入到IMAConversation的_msgList,但未发送,如发送语音,可以用于先在界面上显示,
  37. EIMAMsg_Sending = TIM_MSG_STATUS_SENDING, // 消息发送中
  38. EIMAMsg_SendSucc = TIM_MSG_STATUS_SEND_SUCC, // 消息发送成功
  39. EIMAMsg_SendFail = TIM_MSG_STATUS_SEND_FAIL, // 消息发送失败
  40. // EIMAMsg_Deleted = TIM_MSG_STATUS_HAS_DELETED, // 消息被删除 已经废除,以前删除消息是仅仅把状态置为delete,现在是直接删除存储
  41. };
  42. @interface IMAMsg : NSObject
  43. {
  44. @protected
  45. TIMMessage *_msg;
  46. @protected
  47. IMAMSGType _type;
  48. NSInteger _status;
  49. @protected
  50. // 附加参数,因IMSDK底层有保护机制,从底层获取到的信息,每次都会copy一份
  51. // 使用此参数来优化界面更新
  52. NSMutableDictionary *_affixParams;
  53. }
  54. @property (nonatomic, readonly) IMAMSGType type;
  55. @property (nonatomic, readonly) TIMMessage *msg;
  56. @property (nonatomic, readonly) NSInteger status;
  57. @property (nonatomic, assign) BOOL isPicked;
  58. // 客户从UI界面主动调用的消息类簇
  59. + (instancetype)msgWithText:(NSString *)text;
  60. + (instancetype)msgWithImage:(UIImage *)image isOrignal:(BOOL)origal;
  61. + (instancetype)msgWithDate:(NSDate *)timetip;
  62. + (instancetype)msgWithRevoked:(NSString *)sender;
  63. //
  64. //+ (instancetype)msgWithFile:(NSData *)fileData;
  65. //
  66. + (instancetype)msgWithFilePath:(NSURL *)filePath;
  67. //
  68. + (instancetype)msgWithSound:(NSData *)data duration:(NSInteger)dur;
  69. //+ (instancetype)msgWithSoundPath:(NSString *)path duration:(NSInteger)dur;
  70. + (instancetype)msgWithEmptySound;
  71. + (instancetype)msgWithCustom:(NSInteger)command;
  72. + (instancetype)msgWithCustom:(NSInteger)command param:(NSString *)param;
  73. //
  74. //+ (instancetype)msgWithGroupTips:(NSData *)data;
  75. //
  76. //+ (instancetype)msgWithLocation:(CLLocation *)loc;
  77. //
  78. //+ (instancetype)msgWithCustom:(NSData *)customdata;
  79. //
  80. //+ (instancetype)msgWithFace:(NSInteger)faceIndex;
  81. //
  82. //+ (instancetype)msgWithGroupSystem:(NSString *)tip;
  83. //
  84. //+ (instancetype)msgWithSNSSystem:(NSString *)tip;
  85. //
  86. //+ (instancetype)msgWithProfileSystem:(NSString *)tip;
  87. //
  88. + (instancetype)msgWithVideoPath:(NSString *)videoPath;
  89. // 底层SDK返回后封装的
  90. + (instancetype)msgWith:(TIMMessage *)msg;
  91. - (NSString *)msgTime;
  92. - (NSString *)messageTip;
  93. - (void)changeTo:(IMAMsgStatus)status needRefresh:(BOOL)need;
  94. - (void)remove;
  95. - (IMAUser *)getSender;
  96. // 是否为我发的消息
  97. - (BOOL)isMineMsg;
  98. - (BOOL)isC2CMsg;
  99. - (BOOL)isGroupMsg;
  100. - (BOOL)isSystemMsg;
  101. - (BOOL)isVailedType;
  102. // 是否包含多个文本
  103. - (BOOL)isMultiMsg;
  104. // 外部不调用,只限于TIMAdapter文件目录下代码调用
  105. // affix param method
  106. - (void)addString:(NSString *)aValue forKey:(id<NSCopying>)aKey;
  107. - (void)addInteger:(NSInteger)aValue forKey:(id<NSCopying>)aKey;
  108. - (void)addCGFloat:(CGFloat)aValue forKey:(id<NSCopying>)aKey;
  109. - (void)addBOOL:(BOOL)aValue forKey:(id<NSCopying>)aKey;
  110. - (NSString *)stringForKey:(id<NSCopying>)key;
  111. - (NSInteger)integerForKey:(id<NSCopying>)key;
  112. - (BOOL)boolForKey:(id<NSCopying>)key;
  113. - (CGFloat)floatForKey:(id<NSCopying>)key;
  114. @end